1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
13 func loadStore(roots *x509.CertPool, name string) {
14 store, err := syscall.CertOpenSystemStore(syscall.InvalidHandle, syscall.StringToUTF16Ptr(name))
18 defer syscall.CertCloseStore(store, 0)
20 var cert *syscall.CertContext
22 cert, err = syscall.CertEnumCertificatesInStore(store, cert)
27 buf := (*[1 << 20]byte)(unsafe.Pointer(cert.EncodedCert))[:]
28 // ParseCertificate requires its own copy of certificate data to keep.
29 buf2 := make([]byte, cert.Length)
31 if c, err := x509.ParseCertificate(buf2); err == nil {
37 func initDefaultRoots() {
38 roots := x509.NewCertPool()
41 loadStore(roots, "ROOT")
44 loadStore(roots, "CA")
46 varDefaultRoots = roots