mirror of https://github.com/docker/docs.git
add pkcs11 build tags
Signed-off-by: Jessica Frazelle <acidburn@docker.com> Signed-off-by: David Lawrence <david.lawrence@docker.com> Signed-off-by: Jessica Frazelle <acidburn@docker.com> (github: endophage)
This commit is contained in:
parent
21138e6bad
commit
4648666b7c
|
|
@ -14,8 +14,6 @@ import (
|
||||||
"github.com/docker/notary/client/changelist"
|
"github.com/docker/notary/client/changelist"
|
||||||
"github.com/docker/notary/cryptoservice"
|
"github.com/docker/notary/cryptoservice"
|
||||||
"github.com/docker/notary/keystoremanager"
|
"github.com/docker/notary/keystoremanager"
|
||||||
"github.com/docker/notary/pkg/passphrase"
|
|
||||||
"github.com/docker/notary/signer/api"
|
|
||||||
"github.com/docker/notary/trustmanager"
|
"github.com/docker/notary/trustmanager"
|
||||||
"github.com/docker/notary/tuf"
|
"github.com/docker/notary/tuf"
|
||||||
tufclient "github.com/docker/notary/tuf/client"
|
tufclient "github.com/docker/notary/tuf/client"
|
||||||
|
|
@ -98,44 +96,6 @@ func NewTarget(targetName string, targetPath string) (*Target, error) {
|
||||||
return &Target{Name: targetName, Hashes: meta.Hashes, Length: meta.Length}, nil
|
return &Target{Name: targetName, Hashes: meta.Hashes, Length: meta.Length}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
|
||||||
// (usually ~/.docker/trust/).
|
|
||||||
func NewNotaryRepository(baseDir, gun, baseURL string, rt http.RoundTripper,
|
|
||||||
passphraseRetriever passphrase.Retriever) (*NotaryRepository, error) {
|
|
||||||
|
|
||||||
keyStoreManager, err := keystoremanager.NewKeyStoreManager(baseDir, passphraseRetriever)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
yubiKeyStore := api.NewYubiKeyStore()
|
|
||||||
cryptoService := cryptoservice.NewCryptoService(gun, yubiKeyStore, keyStoreManager.KeyStore)
|
|
||||||
|
|
||||||
nRepo := &NotaryRepository{
|
|
||||||
gun: gun,
|
|
||||||
baseDir: baseDir,
|
|
||||||
baseURL: baseURL,
|
|
||||||
tufRepoPath: filepath.Join(baseDir, tufDir, filepath.FromSlash(gun)),
|
|
||||||
CryptoService: cryptoService,
|
|
||||||
roundTrip: rt,
|
|
||||||
KeyStoreManager: keyStoreManager,
|
|
||||||
}
|
|
||||||
|
|
||||||
fileStore, err := store.NewFilesystemStore(
|
|
||||||
nRepo.tufRepoPath,
|
|
||||||
"metadata",
|
|
||||||
"json",
|
|
||||||
"",
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
nRepo.fileStore = fileStore
|
|
||||||
|
|
||||||
return nRepo, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize creates a new repository by using rootKey as the root Key for the
|
// Initialize creates a new repository by using rootKey as the root Key for the
|
||||||
// TUF repository.
|
// TUF repository.
|
||||||
func (r *NotaryRepository) Initialize(rootKeyID string) error {
|
func (r *NotaryRepository) Initialize(rootKeyID string) error {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
// +build !pkcs11
|
||||||
|
|
||||||
|
package client
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/docker/notary/cryptoservice"
|
||||||
|
"github.com/docker/notary/keystoremanager"
|
||||||
|
"github.com/docker/notary/pkg/passphrase"
|
||||||
|
"github.com/docker/notary/tuf/store"
|
||||||
|
)
|
||||||
|
|
||||||
|
// 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
|
||||||
|
// (usually ~/.docker/trust/).
|
||||||
|
func NewNotaryRepository(baseDir, gun, baseURL string, rt http.RoundTripper,
|
||||||
|
passphraseRetriever passphrase.Retriever) (*NotaryRepository, error) {
|
||||||
|
|
||||||
|
keyStoreManager, err := keystoremanager.NewKeyStoreManager(baseDir, passphraseRetriever)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
cryptoService := cryptoservice.NewCryptoService(gun, keyStoreManager.KeyStore)
|
||||||
|
|
||||||
|
nRepo := &NotaryRepository{
|
||||||
|
gun: gun,
|
||||||
|
baseDir: baseDir,
|
||||||
|
baseURL: baseURL,
|
||||||
|
tufRepoPath: filepath.Join(baseDir, tufDir, filepath.FromSlash(gun)),
|
||||||
|
CryptoService: cryptoService,
|
||||||
|
roundTrip: rt,
|
||||||
|
KeyStoreManager: keyStoreManager,
|
||||||
|
}
|
||||||
|
|
||||||
|
fileStore, err := store.NewFilesystemStore(
|
||||||
|
nRepo.tufRepoPath,
|
||||||
|
"metadata",
|
||||||
|
"json",
|
||||||
|
"",
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
nRepo.fileStore = fileStore
|
||||||
|
|
||||||
|
return nRepo, nil
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
// +build pkcs11
|
||||||
|
|
||||||
|
package client
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/docker/notary/cryptoservice"
|
||||||
|
"github.com/docker/notary/keystoremanager"
|
||||||
|
"github.com/docker/notary/pkg/passphrase"
|
||||||
|
"github.com/docker/notary/signer/api"
|
||||||
|
"github.com/docker/notary/tuf/store"
|
||||||
|
)
|
||||||
|
|
||||||
|
// 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
|
||||||
|
// (usually ~/.docker/trust/).
|
||||||
|
func NewNotaryRepository(baseDir, gun, baseURL string, rt http.RoundTripper,
|
||||||
|
passphraseRetriever passphrase.Retriever) (*NotaryRepository, error) {
|
||||||
|
|
||||||
|
keyStoreManager, err := keystoremanager.NewKeyStoreManager(baseDir, passphraseRetriever)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
yubiKeyStore := api.NewYubiKeyStore()
|
||||||
|
cryptoService := cryptoservice.NewCryptoService(gun, yubiKeyStore, keyStoreManager.KeyStore)
|
||||||
|
|
||||||
|
nRepo := &NotaryRepository{
|
||||||
|
gun: gun,
|
||||||
|
baseDir: baseDir,
|
||||||
|
baseURL: baseURL,
|
||||||
|
tufRepoPath: filepath.Join(baseDir, tufDir, filepath.FromSlash(gun)),
|
||||||
|
CryptoService: cryptoService,
|
||||||
|
roundTrip: rt,
|
||||||
|
KeyStoreManager: keyStoreManager,
|
||||||
|
}
|
||||||
|
|
||||||
|
fileStore, err := store.NewFilesystemStore(
|
||||||
|
nRepo.tufRepoPath,
|
||||||
|
"metadata",
|
||||||
|
"json",
|
||||||
|
"",
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
nRepo.fileStore = fileStore
|
||||||
|
|
||||||
|
return nRepo, nil
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
// +build pkcs11
|
// +build pkcs11
|
||||||
|
|
||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue