2017-04-17 18:08:24 -04:00
|
|
|
// +build pkcs11
|
|
|
|
|
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/docker/notary"
|
|
|
|
"github.com/docker/notary/trustmanager"
|
|
|
|
"github.com/docker/notary/trustmanager/yubikey"
|
|
|
|
)
|
|
|
|
|
2017-08-24 18:40:24 -04:00
|
|
|
func getKeyStores(baseDir string, retriever notary.PassRetriever) ([]trustmanager.KeyStore, error) {
|
2017-04-17 18:08:24 -04:00
|
|
|
fileKeyStore, err := trustmanager.NewKeyFileStore(baseDir, retriever)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("failed to create private key store in directory: %s", baseDir)
|
|
|
|
}
|
|
|
|
|
|
|
|
keyStores := []trustmanager.KeyStore{fileKeyStore}
|
|
|
|
yubiKeyStore, _ := yubikey.NewYubiStore(fileKeyStore, retriever)
|
|
|
|
if yubiKeyStore != nil {
|
|
|
|
keyStores = []trustmanager.KeyStore{yubiKeyStore, fileKeyStore}
|
|
|
|
}
|
2017-08-24 18:40:24 -04:00
|
|
|
return keyStores, nil
|
2017-04-17 18:08:24 -04:00
|
|
|
}
|