1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-31 03:45:17 +00:00

fix: server name without port to generated certificate (#8053)

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
Charles-Edouard Brétéché 2023-08-17 15:05:00 +02:00 committed by GitHub
parent 0d9255ed5a
commit 2e842ec6a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -60,15 +60,14 @@ func generateTLS(server string, caCert *x509.Certificate, caKey *rsa.PrivateKey,
} }
var ips []net.IP var ips []net.IP
if server != "" { if server != "" {
serverHost := "" serverHost := server
if strings.Contains(server, ":") { if strings.Contains(serverHost, ":") {
host, _, err := net.SplitHostPort(server) host, _, err := net.SplitHostPort(serverHost)
if err != nil { 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 serverHost = host
} }
if serverHost != "" {
ip := net.ParseIP(serverHost) ip := net.ParseIP(serverHost)
if ip == nil || ip.IsUnspecified() { if ip == nil || ip.IsUnspecified() {
dnsNames = append(dnsNames, serverHost) dnsNames = append(dnsNames, serverHost)
@ -76,7 +75,6 @@ func generateTLS(server string, caCert *x509.Certificate, caKey *rsa.PrivateKey,
ips = append(ips, ip) ips = append(ips, ip)
} }
} }
}
templ := &x509.Certificate{ templ := &x509.Certificate{
SerialNumber: big.NewInt(1), SerialNumber: big.NewInt(1),
Subject: pkix.Name{ Subject: pkix.Name{