Skip to content

Commit

Permalink
pkg/transport: remove port in Certificate.IPAddresses
Browse files Browse the repository at this point in the history
etcd passes 'url.URL.Host' to 'SelfCert' which contains
client, peer port. 'net.ParseIP("127.0.0.1:2379")' returns
'nil', and the client on this self-cert will see errors
of '127.0.0.1 because it doesn't contain any IP SANs'

Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
  • Loading branch information
gyuho committed Apr 4, 2017
1 parent d6efc0b commit 6fe848e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/transport/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"net"
"os"
"path/filepath"
"strings"
"time"

"github.com/coreos/etcd/pkg/tlsutil"
Expand Down Expand Up @@ -118,10 +117,15 @@ func SelfCert(dirpath string, hosts []string) (info TLSInfo, err error) {
}

for _, host := range hosts {
if ip := net.ParseIP(host); ip != nil {
var h string
h, _, err = net.SplitHostPort(host)
if err != nil {
return
}
if ip := net.ParseIP(h); ip != nil {
tmpl.IPAddresses = append(tmpl.IPAddresses, ip)
} else {
tmpl.DNSNames = append(tmpl.DNSNames, strings.Split(host, ":")[0])
tmpl.DNSNames = append(tmpl.DNSNames, h)
}
}

Expand Down

0 comments on commit 6fe848e

Please sign in to comment.