Skip to content

Commit

Permalink
Fix windows for rootCA
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas JUHEL committed Apr 17, 2020
1 parent ac0339c commit 7c054c4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions njs-certif/tlsTools.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"crypto/x509"
"io/ioutil"
"os"
"runtime"
"strings"

logger "github.com/nabbar/golib/njs-logger"
Expand Down Expand Up @@ -58,15 +59,17 @@ 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()
}
}

func AddRootCAContents(rootContent string) bool {
if rootContent != "" {
if rootContent != "" && rootCA != nil {
return rootCA.AppendCertsFromPEM([]byte(rootContent))
}

Expand Down

0 comments on commit 7c054c4

Please sign in to comment.