From 9edf7d44faa334b65b98ee08a053a3341a9d711a Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Tue, 19 Nov 2013 16:35:00 -0600 Subject: [PATCH] Ensure generated cert contains 127.0.0.1. --- rpcserver.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rpcserver.go b/rpcserver.go index 599ed93b..10f817fb 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -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)