Skip to content

Commit

Permalink
fix certificate not being valid for 127.0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
umbynos committed Apr 7, 2023
1 parent c2507db commit 36e2509
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
10 changes: 2 additions & 8 deletions certificates/certificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,8 @@ func generateSingleCertificate(isCa bool) (*x509.Certificate, error) {
BasicConstraintsValid: true,
}

hosts := strings.Split(host, ",")
for _, h := range hosts {
if ip := net.ParseIP(h); ip != nil {
template.IPAddresses = append(template.IPAddresses, ip)
} else {
template.DNSNames = append(template.DNSNames, h)
}
}
template.IPAddresses = append(template.IPAddresses, net.ParseIP("127.0.0.1"))
template.DNSNames = append(template.DNSNames, "localhost")

if isCa {
template.IsCA = true
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ func loop() {
extraOrigins = append(extraOrigins, "http://localhost:"+port)
extraOrigins = append(extraOrigins, "https://localhost:"+port)
extraOrigins = append(extraOrigins, "http://127.0.0.1:"+port)
extraOrigins = append(extraOrigins, "https://127.0.0.1:"+port)
}

r.Use(cors.Middleware(cors.Config{
Expand Down

0 comments on commit 36e2509

Please sign in to comment.