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

Method LoadLeafCertificates

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

LoadLeafCertificates returns the certificates to be loaded by fl.

()

Source from the content-addressed store, hash-verified

62
63// LoadLeafCertificates returns the certificates to be loaded by fl.
64func (fl LeafFileLoader) LoadLeafCertificates() ([]*x509.Certificate, error) {
65 certificates := make([]*x509.Certificate, 0, len(fl.Files))
66 for _, path := range fl.Files {
67 ders, err := convertPEMFilesToDERBytes(path)
68 if err != nil {
69 return nil, err
70 }
71 certs, err := x509.ParseCertificates(ders)
72 if err != nil {
73 return nil, err
74 }
75 certificates = append(certificates, certs...)
76 }
77 return certificates, nil
78}
79
80func convertPEMFilesToDERBytes(filename string) ([]byte, error) {
81 certDataPEM, err := os.ReadFile(filename)

Callers 1

TestLeafFileLoaderFunction · 0.95

Calls 1

Tested by 1

TestLeafFileLoaderFunction · 0.76