MCPcopy Index your code
hub / github.com/docker/cli / getPrivKeyBytesFromPath

Function getPrivKeyBytesFromPath

cmd/docker-trust/trust/key_load.go:73–91  ·  view source on GitHub ↗
(keyPath string)

Source from the content-addressed store, hash-verified

71}
72
73func getPrivKeyBytesFromPath(keyPath string) ([]byte, error) {
74 if runtime.GOOS != "windows" {
75 fileInfo, err := os.Stat(keyPath)
76 if err != nil {
77 return nil, err
78 }
79 if fileInfo.Mode()&nonOwnerReadWriteMask != 0 {
80 return nil, fmt.Errorf("private key file %s must not be readable or writable by others", keyPath)
81 }
82 }
83
84 from, err := os.OpenFile(keyPath, os.O_RDONLY, notary.PrivExecPerms)
85 if err != nil {
86 return nil, err
87 }
88 defer from.Close()
89
90 return io.ReadAll(from)
91}
92
93func loadPrivKeyBytesToStore(privKeyBytes []byte, privKeyImporters []trustmanager.Importer, keyPath, keyName string, passRet notary.PassRetriever) error {
94 var err error

Callers 4

TestLoadKeyFromPathFunction · 0.85
TestLoadKeyTooPermissiveFunction · 0.85
TestLoadPubKeyFailureFunction · 0.85
loadPrivKeyFunction · 0.85

Calls 2

ModeMethod · 0.80
CloseMethod · 0.45

Tested by 3

TestLoadKeyFromPathFunction · 0.68
TestLoadKeyTooPermissiveFunction · 0.68
TestLoadPubKeyFailureFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…