Skip to content

Commit 213472b

Browse files
authored
fix (testdirectory): fix localhost SAN (#67)
1 parent f5114b0 commit 213472b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

testdirectory/testing.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,13 @@ func GetTLSConfig(t TestingT, opt ...Option) (s *tls.Config, c *tls.Config) {
157157
opts := getOpts(t, opt...)
158158

159159
var ipAddrs []net.IP
160-
if hostIp := net.ParseIP(opts.withHost); hostIp != nil {
161-
ipAddrs = append(ipAddrs, hostIp)
160+
switch {
161+
case opts.withHost == "localhost":
162+
ipAddrs = append(ipAddrs, net.IPv4(127, 0, 0, 1))
163+
default:
164+
if hostIp := net.ParseIP(opts.withHost); hostIp != nil {
165+
ipAddrs = append(ipAddrs, hostIp)
166+
}
162167
}
163168

164169
cert := &x509.Certificate{

0 commit comments

Comments
 (0)