-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
pkg/transport: reload TLS certificates for every use #7784
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,16 +162,26 @@ func (info TLSInfo) baseConfig() (*tls.Config, error) { | |
return nil, fmt.Errorf("KeyFile and CertFile must both be present[key: %v, cert: %v]", info.KeyFile, info.CertFile) | ||
} | ||
|
||
tlsCert, err := tlsutil.NewCert(info.CertFile, info.KeyFile, info.parseFunc) | ||
if err != nil { | ||
return nil, err | ||
cfg := &tls.Config{ | ||
MinVersion: tls.VersionTLS12, | ||
ServerName: info.ServerName, | ||
} | ||
|
||
cfg := &tls.Config{ | ||
Certificates: []tls.Certificate{*tlsCert}, | ||
MinVersion: tls.VersionTLS12, | ||
ServerName: info.ServerName, | ||
cfg.GetCertificate = func(clientHello *tls.ClientHelloInfo) ( | ||
*tls.Certificate, error) { | ||
|
||
// Load the certificate from disk every time so when it is replaced we | ||
// will be using the latest version | ||
return tlsutil.NewCert(info.CertFile, info.KeyFile, info.parseFunc) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. have you benchmarked the overhead of doing this? if this brings a huge overhead, we probably need to do caching. (inotify + caching parsed result or simply pull based caching) |
||
} | ||
cfg.GetClientCertificate = func(unused *tls.CertificateRequestInfo) ( | ||
*tls.Certificate, error) { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this empty line. |
||
// Load the certificate from disk every time so when it is replaced we | ||
// will be using the latest version | ||
return tlsutil.NewCert(info.CertFile, info.KeyFile, info.parseFunc) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also consider caching? |
||
} | ||
|
||
return cfg, nil | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this extra empty line at 172