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:
parent
0d9255ed5a
commit
2e842ec6a3
1 changed files with 9 additions and 11 deletions
|
@ -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{
|
||||||
|
|
Loading…
Add table
Reference in a new issue