Ensure generated cert contains 127.0.0.1.
This commit is contained in:
parent
d18c34a628
commit
9edf7d44fa
1 changed files with 8 additions and 0 deletions
|
@ -359,6 +359,7 @@ func genKey(key, cert string) error {
|
|||
}
|
||||
template.DNSNames = append(template.DNSNames, host, "localhost")
|
||||
|
||||
needLocalhost := true
|
||||
addrs, err := net.InterfaceAddrs()
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -366,9 +367,16 @@ func genKey(key, cert string) error {
|
|||
for _, a := range addrs {
|
||||
ip, _, err := net.ParseCIDR(a.String())
|
||||
if err == nil {
|
||||
if ip.String() == "127.0.0.1" {
|
||||
needLocalhost = false
|
||||
}
|
||||
template.IPAddresses = append(template.IPAddresses, ip)
|
||||
}
|
||||
}
|
||||
if needLocalhost {
|
||||
localHost := net.ParseIP("127.0.0.1")
|
||||
template.IPAddresses = append(template.IPAddresses, localHost)
|
||||
}
|
||||
|
||||
derBytes, err := x509.CreateCertificate(rand.Reader, &template,
|
||||
&template, &priv.PublicKey, priv)
|
||||
|
|
Loading…
Reference in a new issue