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

Function convertPEMToDER

modules/caddytls/leafstorageloader.go:106–123  ·  view source on GitHub ↗
(pemData []byte)

Source from the content-addressed store, hash-verified

104}
105
106func convertPEMToDER(pemData []byte) ([]byte, error) {
107 var ders []byte
108 // while block is not nil, we have more certificates in the file
109 for block, rest := pem.Decode(pemData); block != nil; block, rest = pem.Decode(rest) {
110 if block.Type != "CERTIFICATE" {
111 return nil, fmt.Errorf("no CERTIFICATE pem block found in the given pem data")
112 }
113 ders = append(
114 ders,
115 block.Bytes...,
116 )
117 }
118 // if we decoded nothing, return an error
119 if len(ders) == 0 {
120 return nil, fmt.Errorf("no CERTIFICATE pem block found in the given pem data")
121 }
122 return ders, nil
123}
124
125// Interface guard
126var (

Callers 2

LoadLeafCertificatesMethod · 0.85
LoadLeafCertificatesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected