Skip to content

Commit

Permalink
fix: server name without port to generated certificate (kyverno#8053)
Browse files Browse the repository at this point in the history
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
  • Loading branch information
eddycharly authored Aug 17, 2023
1 parent 0d9255e commit 2e842ec
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions pkg/tls/keypair.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,19 @@ func generateTLS(server string, caCert *x509.Certificate, caKey *rsa.PrivateKey,
}
var ips []net.IP
if server != "" {
serverHost := ""
if strings.Contains(server, ":") {
host, _, err := net.SplitHostPort(server)
serverHost := server
if strings.Contains(serverHost, ":") {
host, _, err := net.SplitHostPort(serverHost)
if err != nil {
logger.Error(err, "failed to split server host/port", "server", server)
logger.Error(err, "failed to split server host/port", "server", serverHost)
}
serverHost = host
}
if serverHost != "" {
ip := net.ParseIP(serverHost)
if ip == nil || ip.IsUnspecified() {
dnsNames = append(dnsNames, serverHost)
} else {
ips = append(ips, ip)
}
ip := net.ParseIP(serverHost)
if ip == nil || ip.IsUnspecified() {
dnsNames = append(dnsNames, serverHost)
} else {
ips = append(ips, ip)
}
}
templ := &x509.Certificate{
Expand Down

0 comments on commit 2e842ec

Please sign in to comment.