-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Use default entryPoints when certificates are added with no entryPoints. #2534
Use default entryPoints when certificates are added with no entryPoints. #2534
Conversation
tls/tls.go
Outdated
if len(certName) > 50 { | ||
certName = certName[0:50] | ||
} | ||
log.Debugf("No entryPoint is defined to add the certificate %s, it will be added to the default entryPoints: %s", certName, strings.Join(defaultEntryPoints, ",")) |
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.
if log.GetLevel() >= logrus.DebugLevel {
certName := conf.Certificate.CertFile.String()
// Keep only 50 characters to generate a readable log
if len(certName) > 50 {
certName = certName[:50]
}
log.Debugf("No entryPoint is defined to add the certificate %s, it will be added to the default entryPoints: %s", certName, strings.Join(defaultEntryPoints, ","))
}
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.
LGTM
9e5f1c0
to
3bff3b0
Compare
tls/tls.go
Outdated
if conf.Certificate.CertFile.Path() { | ||
certName = conf.Certificate.CertFile.String() | ||
} else { | ||
certName = strings.TrimPrefix(conf.Certificate.CertFile.String(), "-----BEGIN CERTIFICATE-----\n")[:50] |
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.
if the CertFile content if empty or malformed, this can panicing.
tls/tls.go
Outdated
if log.GetLevel() >= logrus.DebugLevel { | ||
certName := conf.Certificate.CertFile.String() | ||
// Truncate certificate information only if it's a well formed certificate content with more than 50 characters | ||
if !conf.Certificate.CertFile.Path() && strings.Index(conf.Certificate.CertFile.String(), certificateHeader) == 0 && len(conf.Certificate.CertFile.String()) > 50 { |
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.
HasPrefix
instead of Index
?
You need to compare len
with 50+len(certificateHeader)
tls/certificate.go
Outdated
@@ -67,6 +67,12 @@ func (f FileOrContent) String() string { | |||
return string(f) | |||
} | |||
|
|||
// Path returns true if the FileOrContent is a file path, otherwise returns false | |||
func (f FileOrContent) Path() bool { |
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.
if it's a boolean, isPath
or you must return a string with filepath if you have one ?
@@ -435,8 +435,12 @@ func (s *Server) loadConfiguration(configMsg types.ConfigMessage) { | |||
if err == nil { | |||
for newServerEntryPointName, newServerEntryPoint := range newServerEntryPoints { | |||
s.serverEntryPoints[newServerEntryPointName].httpRouter.UpdateHandler(newServerEntryPoint.httpRouter.GetHandler()) | |||
if &newServerEntryPoint.certs != nil { | |||
s.serverEntryPoints[newServerEntryPointName].certs.Set(newServerEntryPoint.certs.Get()) | |||
if newServerEntryPoint.certs.Get() != 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.
certs can be 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.
It's not possible because it's a struct and not a pointer
995acc9
to
546c710
Compare
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.
LGTM
546c710
to
29b61e6
Compare
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.
LGTM
What does this PR do?
The PR allows introducing a mechanism by default for all the providers which add TLScertificates dynamically.
If no entryPoints are given, the certificates are added to all of the
defaultEntryPoints
(from Træfik global configuration) wich have a TLS configuration.Motivation
This PR helps to create the certificates management from K8s secret (#2439)
More