Skip to content

Commit

Permalink
fix: x509 error in windows7/8
Browse files Browse the repository at this point in the history
  • Loading branch information
wwqgtxx committed May 12, 2024
1 parent 619f341 commit b840eae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 0 additions & 3 deletions component/ca/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ func ResetCertificate() {
}

func getCertPool() *x509.CertPool {
if len(trustCerts) == 0 {
return nil
}
if globalCertPool == nil {
mutex.Lock()
defer mutex.Unlock()
Expand Down
15 changes: 15 additions & 0 deletions component/ca/fix_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package ca

import (
"golang.org/x/sys/windows"
)

func init() {
majorVersion, _, _ := windows.RtlGetNtVersionNumbers()
// crypto/x509: certificate validation in Windows fails to validate IP in SAN
// https://github.com/golang/go/issues/37176
// As far as I can tell this is still the case on most older versions of Windows (but seems to be fixed in 10)
if majorVersion < 10 && len(_CaCertificates) > 0 {
DisableSystemCa = true
}
}

0 comments on commit b840eae

Please sign in to comment.