(kmsURI, name string, opts ...pemutil.Options)
| 50 | } |
| 51 | |
| 52 | func PublicKey(kmsURI, name string, opts ...pemutil.Options) (crypto.PublicKey, error) { |
| 53 | if isFilename(name) { |
| 54 | s, err := pemutil.Read(name, opts...) |
| 55 | if err != nil { |
| 56 | return nil, err |
| 57 | } |
| 58 | if pub, ok := s.(crypto.PublicKey); ok { |
| 59 | return pub, nil |
| 60 | } |
| 61 | return nil, fmt.Errorf("file %s does not contain a valid public key", name) |
| 62 | } |
| 63 | |
| 64 | k, err := newKMSPublicKey(kmsURI, name) |
| 65 | if err != nil { |
| 66 | return nil, fmt.Errorf("failed to get public key: %w", err) |
| 67 | } |
| 68 | |
| 69 | return k.Public(), nil |
| 70 | } |
| 71 | |
| 72 | // CreateSigner reads a key from a file with a given name or creates a signer |
| 73 | // with the given kms and name uri. |
no test coverage detected
searching dependent graphs…