golang-mtls-example/pkg/castore/castore.go

21 lines
344 B
Go

package castore
import (
"crypto/x509"
_ "embed"
"log"
"os"
)
//go:embed ca.crt
var CACert []byte
func NewCAstore() *x509.CertPool {
logger := log.New(os.Stderr, "", log.Lshortfile)
certPool := x509.NewCertPool()
if !certPool.AppendCertsFromPEM(CACert) {
logger.Fatal("Can't append CertPool with embedded CA")
}
return certPool
}