Use default entryPoints when certificates are added with no entryPoints.
This commit is contained in:
parent
c66d9de759
commit
c446c291d9
7 changed files with 72 additions and 20 deletions
20
tls/tls.go
20
tls/tls.go
|
@ -4,6 +4,13 @@ import (
|
|||
"crypto/tls"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/containous/traefik/log"
|
||||
)
|
||||
|
||||
const (
|
||||
certificateHeader = "-----BEGIN CERTIFICATE-----\n"
|
||||
)
|
||||
|
||||
// ClientCA defines traefik CA files for a entryPoint
|
||||
|
@ -87,11 +94,22 @@ func (r *RootCAs) Type() string {
|
|||
}
|
||||
|
||||
// SortTLSConfigurationPerEntryPoints converts TLS configuration sorted by Certificates into TLS configuration sorted by EntryPoints
|
||||
func SortTLSConfigurationPerEntryPoints(configurations []*Configuration, epConfiguration map[string]*DomainsCertificates) error {
|
||||
func SortTLSConfigurationPerEntryPoints(configurations []*Configuration, epConfiguration map[string]*DomainsCertificates, defaultEntryPoints []string) error {
|
||||
if epConfiguration == nil {
|
||||
epConfiguration = make(map[string]*DomainsCertificates)
|
||||
}
|
||||
for _, conf := range configurations {
|
||||
if conf.EntryPoints == nil || len(conf.EntryPoints) == 0 {
|
||||
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.IsPath() && strings.HasPrefix(conf.Certificate.CertFile.String(), certificateHeader) && len(conf.Certificate.CertFile.String()) > len(certificateHeader)+50 {
|
||||
certName = strings.TrimPrefix(conf.Certificate.CertFile.String(), certificateHeader)[: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, ", "))
|
||||
}
|
||||
conf.EntryPoints = append(conf.EntryPoints, defaultEntryPoints...)
|
||||
}
|
||||
for _, ep := range conf.EntryPoints {
|
||||
if err := conf.Certificate.AppendCertificates(epConfiguration, ep); err != nil {
|
||||
return err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue