Merge pull request #2666 from cosmos/alessio/2664-fix-dns-alt-name
[R4R] Include DNS alt name in certificate
This commit is contained in:
commit
22ef9443d6
|
@ -38,12 +38,13 @@ func generateSelfSignedCert(host string) (certBytes []byte, priv *ecdsa.PrivateK
|
||||||
Subject: pkix.Name{
|
Subject: pkix.Name{
|
||||||
Organization: []string{"Gaia Lite"},
|
Organization: []string{"Gaia Lite"},
|
||||||
},
|
},
|
||||||
|
DNSNames: []string{"localhost"},
|
||||||
NotBefore: notBefore,
|
NotBefore: notBefore,
|
||||||
NotAfter: notAfter,
|
NotAfter: notAfter,
|
||||||
KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,
|
KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,
|
||||||
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},
|
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth},
|
||||||
BasicConstraintsValid: true,
|
BasicConstraintsValid: true,
|
||||||
IsCA: true,
|
IsCA: true,
|
||||||
}
|
}
|
||||||
hosts := strings.Split(host, ",")
|
hosts := strings.Split(host, ",")
|
||||||
for _, h := range hosts {
|
for _, h := range hosts {
|
||||||
|
|
|
@ -17,7 +17,7 @@ func TestGenerateSelfSignedCert(t *testing.T) {
|
||||||
cert, err := x509.ParseCertificate(certBytes)
|
cert, err := x509.ParseCertificate(certBytes)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
require.Equal(t, 2, len(cert.IPAddresses))
|
require.Equal(t, 2, len(cert.IPAddresses))
|
||||||
require.Equal(t, 1, len(cert.DNSNames))
|
require.Equal(t, 2, len(cert.DNSNames))
|
||||||
require.True(t, cert.IsCA)
|
require.True(t, cert.IsCA)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue