Skip to content

Commit

Permalink
Do not send empty certificates to nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Jun 25, 2019
1 parent d57fdde commit 8ca5c1c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions internal/ingress/controller/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -994,15 +994,18 @@ func configureCertificates(pcfg *ingress.Configuration) error {
var servers []*ingress.Server

for _, server := range pcfg.Servers {
if server.SSLCert.PemCertKey == "" {
continue
}

servers = append(servers, &ingress.Server{
Hostname: server.Hostname,
SSLCert: ingress.SSLCert{
PemCertKey: server.SSLCert.PemCertKey,
},
})

if server.Alias != "" && server.SSLCert.PemCertKey != "" &&
ssl.IsValidHostname(server.Alias, server.SSLCert.CN) {
if server.Alias != "" && ssl.IsValidHostname(server.Alias, server.SSLCert.CN) {
servers = append(servers, &ingress.Server{
Hostname: server.Alias,
SSLCert: ingress.SSLCert{
Expand All @@ -1014,6 +1017,10 @@ func configureCertificates(pcfg *ingress.Configuration) error {

redirects := buildRedirects(pcfg.Servers)
for _, redirect := range redirects {
if redirect.SSLCert.PemCertKey == "" {
continue
}

servers = append(servers, &ingress.Server{
Hostname: redirect.From,
SSLCert: ingress.SSLCert{
Expand Down
2 changes: 1 addition & 1 deletion internal/ingress/sslcert.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type SSLCert struct {
// ExpiresTime contains the expiration of this SSL certificate in timestamp format
ExpireTime time.Time `json:"expires"`
// Pem encoded certificate and key concatenated
PemCertKey string `json:"pemCertKey"`
PemCertKey string `json:"pemCertKey,omitempty"`
}

// GetObjectKind implements the ObjectKind interface as a noop
Expand Down

0 comments on commit 8ca5c1c

Please sign in to comment.