MCPcopy Index your code
hub / github.com/smallstep/cli / tlsLoadX509KeyPair

Function tlsLoadX509KeyPair

command/ca/renew.go:656–679  ·  view source on GitHub ↗
(kms, certFile, keyFile, passFile string)

Source from the content-addressed store, hash-verified

654}
655
656func tlsLoadX509KeyPair(kms, certFile, keyFile, passFile string) (tls.Certificate, error) {
657 x509Chain, err := pemutil.ReadCertificateBundle(certFile)
658 if err != nil {
659 return tls.Certificate{}, errs.Wrap(err, "error reading certificate chain")
660 }
661 x509ChainBytes := make([][]byte, len(x509Chain))
662 for i, c := range x509Chain {
663 x509ChainBytes[i] = c.Raw
664 }
665
666 opts := []pemutil.Options{pemutil.WithFilename(keyFile)}
667 if passFile != "" {
668 opts = append(opts, pemutil.WithPasswordFile(passFile))
669 }
670 signer, err := cryptoutil.CreateSigner(kms, keyFile, opts...)
671 if err != nil {
672 return tls.Certificate{}, errs.Wrap(err, "error loading private key")
673 }
674 return tls.Certificate{
675 Certificate: x509ChainBytes,
676 PrivateKey: signer,
677 Leaf: x509Chain[0],
678 }, nil
679}

Callers 2

rekeyCertificateActionFunction · 0.85
renewCertificateActionFunction · 0.85

Calls 1

CreateSignerFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…