Skip to content

Commit 36e2509

Browse files
committed
fix certificate not being valid for 127.0.0.1
1 parent c2507db commit 36e2509

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

certificates/certificates.go

+2-8
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,8 @@ func generateSingleCertificate(isCa bool) (*x509.Certificate, error) {
127127
BasicConstraintsValid: true,
128128
}
129129

130-
hosts := strings.Split(host, ",")
131-
for _, h := range hosts {
132-
if ip := net.ParseIP(h); ip != nil {
133-
template.IPAddresses = append(template.IPAddresses, ip)
134-
} else {
135-
template.DNSNames = append(template.DNSNames, h)
136-
}
137-
}
130+
template.IPAddresses = append(template.IPAddresses, net.ParseIP("127.0.0.1"))
131+
template.DNSNames = append(template.DNSNames, "localhost")
138132

139133
if isCa {
140134
template.IsCA = true

main.go

+1
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ func loop() {
350350
extraOrigins = append(extraOrigins, "http://localhost:"+port)
351351
extraOrigins = append(extraOrigins, "https://localhost:"+port)
352352
extraOrigins = append(extraOrigins, "http://127.0.0.1:"+port)
353+
extraOrigins = append(extraOrigins, "https://127.0.0.1:"+port)
353354
}
354355

355356
r.Use(cors.Middleware(cors.Config{

0 commit comments

Comments
 (0)