diff --git a/njs-certif/tlsTools.go b/njs-certif/tlsTools.go index 0949cb39..ee5d1563 100644 --- a/njs-certif/tlsTools.go +++ b/njs-certif/tlsTools.go @@ -29,6 +29,7 @@ import ( "crypto/x509" "io/ioutil" "os" + "runtime" "strings" logger "github.com/nabbar/golib/njs-logger" @@ -58,7 +59,9 @@ func init() { } func InitRootCA() { - if c, e := x509.SystemCertPool(); e != nil { + if runtime.GOOS == "windows" { + rootCA = x509.NewCertPool() + } else if c, e := x509.SystemCertPool(); e != nil { rootCA = c } else { rootCA = x509.NewCertPool() @@ -66,7 +69,7 @@ func InitRootCA() { } func AddRootCAContents(rootContent string) bool { - if rootContent != "" { + if rootContent != "" && rootCA != nil { return rootCA.AppendCertsFromPEM([]byte(rootContent)) }