OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [crypto/] [tls/] [root_windows.go] - Blame information for rev 761

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// 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.
4
 
5
package tls
6
 
7
import (
8
        "crypto/x509"
9
        "syscall"
10
        "unsafe"
11
)
12
 
13
func loadStore(roots *x509.CertPool, name string) {
14
        store, err := syscall.CertOpenSystemStore(syscall.InvalidHandle, syscall.StringToUTF16Ptr(name))
15
        if err != nil {
16
                return
17
        }
18
        defer syscall.CertCloseStore(store, 0)
19
 
20
        var cert *syscall.CertContext
21
        for {
22
                cert, err = syscall.CertEnumCertificatesInStore(store, cert)
23
                if err != nil {
24
                        return
25
                }
26
 
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)
30
                copy(buf2, buf)
31
                if c, err := x509.ParseCertificate(buf2); err == nil {
32
                        roots.AddCert(c)
33
                }
34
        }
35
}
36
 
37
func initDefaultRoots() {
38
        roots := x509.NewCertPool()
39
 
40
        // Roots
41
        loadStore(roots, "ROOT")
42
 
43
        // Intermediates
44
        loadStore(roots, "CA")
45
 
46
        varDefaultRoots = roots
47
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.