CreateSigner reads a key from a file with a given name or creates a signer with the given kms and name uri.
(kmsURI, name string, opts ...pemutil.Options)
| 72 | // CreateSigner reads a key from a file with a given name or creates a signer |
| 73 | // with the given kms and name uri. |
| 74 | func CreateSigner(kmsURI, name string, opts ...pemutil.Options) (crypto.Signer, error) { |
| 75 | if isFilename(name) { |
| 76 | s, err := pemutil.Read(name, opts...) |
| 77 | if err != nil { |
| 78 | return nil, err |
| 79 | } |
| 80 | if sig, ok := s.(crypto.Signer); ok { |
| 81 | return sig, nil |
| 82 | } |
| 83 | return nil, fmt.Errorf("file %s does not contain a valid private key", name) |
| 84 | } |
| 85 | |
| 86 | return newKMSSigner(kmsURI, name) |
| 87 | } |
| 88 | |
| 89 | // LoadCertificate returns a x509.Certificate from a kms or file |
| 90 | func LoadCertificate(kmsURI, certPath string) ([]*x509.Certificate, error) { |
no test coverage detected
searching dependent graphs…