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

Function LoadCertificate

internal/cryptoutil/cryptoutil.go:90–123  ·  view source on GitHub ↗

LoadCertificate returns a x509.Certificate from a kms or file

(kmsURI, certPath string)

Source from the content-addressed store, hash-verified

88
89// LoadCertificate returns a x509.Certificate from a kms or file
90func LoadCertificate(kmsURI, certPath string) ([]*x509.Certificate, error) {
91 if isFilename(certPath) {
92 s, err := pemutil.ReadCertificateBundle(certPath)
93 if err != nil {
94 return nil, fmt.Errorf("file %s does not contain a valid certificate: %w", certPath, err)
95 }
96 return s, nil
97 }
98
99 name, err := plugin.LookPath("kms")
100 if err != nil {
101 return nil, err
102 }
103
104 args := []string{"certificate"}
105 if kmsURI != "" {
106 args = append(args, "--kms", kmsURI)
107 }
108 args = append(args, certPath)
109
110 // Get public key
111 cmd := exec.Command(name, args...)
112 out, err := cmd.Output()
113 if err != nil {
114 return nil, exitError(cmd, err)
115 }
116
117 cert, err := pemutil.ParseCertificateBundle(out)
118 if err != nil {
119 return nil, err
120 }
121
122 return cert, nil
123}
124
125// LoadJSONWebKey returns a jose.JSONWebKey from a KMS or a file.
126func LoadJSONWebKey(kmsURI, name string, opts ...jose.Option) (*jose.JSONWebKey, error) {

Callers 2

generateX5CTokenFunction · 0.92
signActionFunction · 0.92

Calls 3

LookPathFunction · 0.92
isFilenameFunction · 0.85
exitErrorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…