MCPcopy Create free account
hub / github.com/XTLS/Go / LoadX509KeyPair

Function LoadX509KeyPair

tls.go:230–240  ·  view source on GitHub ↗

LoadX509KeyPair reads and parses a public/private key pair from a pair of files. The files must contain PEM encoded data. The certificate file may contain intermediate certificates following the leaf certificate to form a certificate chain. On successful return, Certificate.Leaf will be nil because

(certFile, keyFile string)

Source from the content-addressed store, hash-verified

228// form a certificate chain. On successful return, Certificate.Leaf will
229// be nil because the parsed form of the certificate is not retained.
230func LoadX509KeyPair(certFile, keyFile string) (Certificate, error) {
231 certPEMBlock, err := os.ReadFile(certFile)
232 if err != nil {
233 return Certificate{}, err
234 }
235 keyPEMBlock, err := os.ReadFile(keyFile)
236 if err != nil {
237 return Certificate{}, err
238 }
239 return X509KeyPair(certPEMBlock, keyPEMBlock)
240}
241
242// X509KeyPair parses a public/private key pair from a pair of
243// PEM encoded data. On successful return, Certificate.Leaf will be nil because

Callers

nothing calls this directly

Calls 1

X509KeyPairFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…