MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / loadCert

Function loadCert

sqlchain/adapter/config/config.go:190–210  ·  view source on GitHub ↗
(pemFile string)

Source from the content-addressed store, hash-verified

188}
189
190func loadCert(pemFile string) (cert *x509.Certificate, err error) {
191 // only the first pem section is parsed and identified as certificate.
192 var certBytes []byte
193
194 if certBytes, err = ioutil.ReadFile(pemFile); err != nil {
195 return
196 }
197
198 var pemBlock *pem.Block
199 if pemBlock, _ = pem.Decode(certBytes); pemBlock == nil {
200 err = ErrInvalidCertificateFile
201 return
202 }
203
204 if pemBlock.Type != "CERTIFICATE" || len(pemBlock.Headers) != 0 {
205 err = ErrInvalidCertificateFile
206 return
207 }
208
209 return x509.ParseCertificate(pemBlock.Bytes)
210}

Callers 1

LoadConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected