2015-10-30 17:31:02 -07:00
|
|
|
// +build !pkcs11
|
|
|
|
|
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
|
2016-09-21 16:18:22 -07:00
|
|
|
"github.com/docker/notary"
|
2015-10-30 17:31:02 -07:00
|
|
|
"github.com/docker/notary/trustmanager"
|
2016-04-25 10:21:28 -07:00
|
|
|
"github.com/docker/notary/trustpinning"
|
2015-10-30 17:31:02 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
// NewNotaryRepository is a helper method that returns a new notary repository.
|
|
|
|
// It takes the base directory under where all the trust files will be stored
|
2016-05-11 15:25:05 -07:00
|
|
|
// (This is normally defaults to "~/.notary" or "~/.docker/trust" when enabling
|
|
|
|
// docker content trust).
|
2015-10-30 17:31:02 -07:00
|
|
|
func NewNotaryRepository(baseDir, gun, baseURL string, rt http.RoundTripper,
|
2016-09-21 16:18:22 -07:00
|
|
|
retriever notary.PassRetriever, trustPinning trustpinning.TrustPinConfig) (
|
2015-12-18 18:47:35 -08:00
|
|
|
*NotaryRepository, error) {
|
|
|
|
|
2015-10-30 17:31:02 -07:00
|
|
|
fileKeyStore, err := trustmanager.NewKeyFileStore(baseDir, retriever)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("failed to create private key store in directory: %s", baseDir)
|
|
|
|
}
|
|
|
|
|
2015-12-18 18:47:35 -08:00
|
|
|
return repositoryFromKeystores(baseDir, gun, baseURL, rt,
|
2016-04-25 10:21:28 -07:00
|
|
|
[]trustmanager.KeyStore{fileKeyStore}, trustPinning)
|
2015-10-30 17:31:02 -07:00
|
|
|
}
|