From 7c054c4f25da269a166e37c61b0888a6893a2fd2 Mon Sep 17 00:00:00 2001 From: Nicolas JUHEL Date: Fri, 17 Apr 2020 14:31:14 +0200 Subject: [PATCH] Fix windows for rootCA --- njs-certif/tlsTools.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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)) }