Commit ec10d677 authored by Mikkel Krautz's avatar Mikkel Krautz Committed by Russ Cox

crypto/tls: fix broken looping code in windows root CA fetcher

R=alex.brainman, hectorchu, rsc
CC=golang-dev
https://golang.org/cl/5263045
parent bb282baa
...@@ -17,35 +17,31 @@ func loadStore(roots *x509.CertPool, name string) { ...@@ -17,35 +17,31 @@ func loadStore(roots *x509.CertPool, name string) {
return return
} }
var prev *syscall.CertContext var cert *syscall.CertContext
for { for {
cur := syscall.CertEnumCertificatesInStore(store, prev) cert = syscall.CertEnumCertificatesInStore(store, cert)
if cur == nil { if cert == nil {
break break
} }
var buf []byte var asn1Slice []byte
hdrp := (*reflect.SliceHeader)(unsafe.Pointer(&buf)) hdrp := (*reflect.SliceHeader)(unsafe.Pointer(&asn1Slice))
hdrp.Data = cur.EncodedCert hdrp.Data = cert.EncodedCert
hdrp.Len = int(cur.Length) hdrp.Len = int(cert.Length)
hdrp.Cap = int(cur.Length) hdrp.Cap = int(cert.Length)
cert, err := x509.ParseCertificate(buf) buf := make([]byte, len(asn1Slice))
if err != nil { copy(buf, asn1Slice)
continue
}
roots.AddCert(cert) if cert, err := x509.ParseCertificate(buf); err == nil {
prev = cur roots.AddCert(cert)
}
} }
syscall.CertCloseStore(store, 0) syscall.CertCloseStore(store, 0)
} }
func initDefaultRoots() { func initDefaultRoots() {
// TODO(brainman): To be fixed
return
roots := x509.NewCertPool() roots := x509.NewCertPool()
// Roots // Roots
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment