MCPcopy Create free account
hub / github.com/docker/cli / loadPrivKeyBytesToStore

Function loadPrivKeyBytesToStore

cmd/docker-trust/trust/key_load.go:93–103  ·  view source on GitHub ↗
(privKeyBytes []byte, privKeyImporters []trustmanager.Importer, keyPath, keyName string, passRet notary.PassRetriever)

Source from the content-addressed store, hash-verified

91}
92
93func loadPrivKeyBytesToStore(privKeyBytes []byte, privKeyImporters []trustmanager.Importer, keyPath, keyName string, passRet notary.PassRetriever) error {
94 var err error
95 if _, _, err = tufutils.ExtractPrivateKeyAttributes(privKeyBytes); err != nil {
96 return fmt.Errorf("provided file %s is not a supported private key - to add a signer's public key use docker trust signer add", keyPath)
97 }
98 if privKeyBytes, err = decodePrivKeyIfNecessary(privKeyBytes, passRet); err != nil {
99 return fmt.Errorf("cannot load key from provided file %s: %w", keyPath, err)
100 }
101 // Make a reader, rewind the file pointer
102 return trustmanager.ImportKeys(bytes.NewReader(privKeyBytes), privKeyImporters, keyName, "", passRet)
103}
104
105func decodePrivKeyIfNecessary(privPemBytes []byte, passRet notary.PassRetriever) ([]byte, error) {
106 pemBlock, _ := pem.Decode(privPemBytes)

Callers 3

TestLoadKeyFromPathFunction · 0.85
TestLoadPubKeyFailureFunction · 0.85
loadPrivKeyFunction · 0.85

Calls 1

decodePrivKeyIfNecessaryFunction · 0.85

Tested by 2

TestLoadKeyFromPathFunction · 0.68
TestLoadPubKeyFailureFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…