Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not load certificates if GetCertificate is provided #173

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions diam/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,10 @@ func ListenAndServe(addr string, handler Handler, dp *dict.Parser) error {
// ListenAndServeTLS listens on the network address srv.Addr and
// then calls Serve to handle requests on incoming TLS connections.
//
// Filenames containing a certificate and matching private key for
// the server must be provided. If the certificate is signed by a
// Either filenames containing a certificate and matching private key
// for the server must be provided either the callback
// srv.TLSConfig.GetCertificate should be filled in advance.
// If the certificate is signed by a
// certificate authority, the certFile should be the concatenation
// of the server's certificate followed by the CA's certificate.
//
Expand All @@ -694,11 +696,13 @@ func (srv *Server) ListenAndServeTLS(certFile, keyFile string) error {
config = TLSConfigClone(srv.TLSConfig)
}
var err error
config.Certificates = make([]tls.Certificate, 1)
config.Certificates[0], err = tls.LoadX509KeyPair(certFile, keyFile)
if err != nil {
return err
}
if config.GetCertificate == nil {
config.Certificates = make([]tls.Certificate, 1)
config.Certificates[0], err = tls.LoadX509KeyPair(certFile, keyFile)
if err != nil {
return err
}
}
conn, err := Listen(network, addr)
if err != nil {
return err
Expand Down