MCPcopy
hub / github.com/caddyserver/caddy / LoadLeafCertificates

Method LoadLeafCertificates

modules/caddytls/leafpemloader.go:64–78  ·  view source on GitHub ↗

LoadLeafCertificates returns the certificates contained in pl.

()

Source from the content-addressed store, hash-verified

62
63// LoadLeafCertificates returns the certificates contained in pl.
64func (pl LeafPEMLoader) LoadLeafCertificates() ([]*x509.Certificate, error) {
65 certs := make([]*x509.Certificate, 0, len(pl.Certificates))
66 for i, cert := range pl.Certificates {
67 derBytes, err := convertPEMToDER([]byte(cert))
68 if err != nil {
69 return nil, fmt.Errorf("PEM leaf certificate loader, cert %d: %v", i, err)
70 }
71 cert, err := x509.ParseCertificate(derBytes)
72 if err != nil {
73 return nil, fmt.Errorf("PEM cert %d: %v", i, err)
74 }
75 certs = append(certs, cert)
76 }
77 return certs, nil
78}
79
80// Interface guard
81var (

Callers 1

TestLeafPEMLoaderFunction · 0.95

Calls 1

convertPEMToDERFunction · 0.85

Tested by 1

TestLeafPEMLoaderFunction · 0.76