MCPcopy Create free account
hub / github.com/SenseUnit/dumbproxy / ExpectPeerName

Function ExpectPeerName

tlsutil/util.go:15–28  ·  view source on GitHub ↗
(name string, roots *x509.CertPool)

Source from the content-addressed store, hash-verified

13)
14
15func ExpectPeerName(name string, roots *x509.CertPool) func(cs tls.ConnectionState) error {
16 return func(cs tls.ConnectionState) error {
17 opts := x509.VerifyOptions{
18 Roots: roots,
19 DNSName: name,
20 Intermediates: x509.NewCertPool(),
21 }
22 for _, cert := range cs.PeerCertificates[1:] {
23 opts.Intermediates.AddCert(cert)
24 }
25 _, err := cs.PeerCertificates[0].Verify(opts)
26 return err
27 }
28}
29
30func LoadCAfile(filename string) (*x509.CertPool, error) {
31 roots := x509.NewCertPool()

Callers 1

TLSConfigFromURLFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected