Rename pki.FindKeypair to FindPrimaryKeypair

This commit is contained in:
John Gardiner Myers 2021-05-03 20:59:54 -07:00
parent 2a431c03a9
commit 2300d89591
10 changed files with 20 additions and 20 deletions

View File

@ -35,7 +35,7 @@ type keystoreEntry struct {
var _ pki.Keystore = keystore{} var _ pki.Keystore = keystore{}
func (k keystore) FindKeypair(name string) (*pki.Certificate, *pki.PrivateKey, error) { func (k keystore) FindPrimaryKeypair(name string) (*pki.Certificate, *pki.PrivateKey, error) {
entry, ok := k.keys[name] entry, ok := k.keys[name]
if !ok { if !ok {
return nil, nil, fmt.Errorf("unknown CA %q", name) return nil, nil, fmt.Errorf("unknown CA %q", name)

View File

@ -63,7 +63,7 @@ func (s *Server) getNodeConfig(ctx context.Context, req *nodeup.BootstrapRequest
// We populate some certificates that we know the node will need. // We populate some certificates that we know the node will need.
for _, name := range []string{"ca"} { for _, name := range []string{"ca"} {
cert, _, err := s.keystore.FindKeypair(name) cert, _, err := s.keystore.FindPrimaryKeypair(name)
if err != nil { if err != nil {
return nil, fmt.Errorf("error getting certificate %q: %w", name, err) return nil, fmt.Errorf("error getting certificate %q: %w", name, err)
} }

View File

@ -33,8 +33,8 @@ type fakeKeyStore struct {
var _ fi.Keystore = &fakeKeyStore{} var _ fi.Keystore = &fakeKeyStore{}
func (k fakeKeyStore) FindKeypair(name string) (*pki.Certificate, *pki.PrivateKey, error) { func (k fakeKeyStore) FindPrimaryKeypair(name string) (*pki.Certificate, *pki.PrivateKey, error) {
panic("fakeKeyStore does not implement FindKeypair") panic("fakeKeyStore does not implement FindPrimaryKeypair")
} }
func (k fakeKeyStore) FindKeyset(name string) (*fi.Keyset, error) { func (k fakeKeyStore) FindKeyset(name string) (*fi.Keyset, error) {

View File

@ -38,9 +38,9 @@ func NewKeyStore(nodeConfig *nodeup.NodeConfig) fi.CAStore {
} }
} }
// FindKeypair implements pki.Keystore // FindPrimaryKeypair implements pki.Keystore
func (s *configserverKeyStore) FindKeypair(name string) (*pki.Certificate, *pki.PrivateKey, error) { func (s *configserverKeyStore) FindPrimaryKeypair(name string) (*pki.Certificate, *pki.PrivateKey, error) {
return nil, nil, fmt.Errorf("FindKeypair %q not supported by configserverKeyStore", name) return nil, nil, fmt.Errorf("FindPrimaryKeypair %q not supported by configserverKeyStore", name)
} }
// FindKeyset implements fi.Keystore // FindKeyset implements fi.Keystore

View File

@ -94,8 +94,8 @@ type fakeKeyStore struct {
MirrorToFn func(basedir vfs.Path) error MirrorToFn func(basedir vfs.Path) error
} }
func (f fakeKeyStore) FindKeypair(name string) (*pki.Certificate, *pki.PrivateKey, error) { func (f fakeKeyStore) FindPrimaryKeypair(name string) (*pki.Certificate, *pki.PrivateKey, error) {
return fi.FindKeypair(f, name) return fi.FindPrimaryKeypair(f, name)
} }
func (f fakeKeyStore) FindKeyset(name string) (*fi.Keyset, error) { func (f fakeKeyStore) FindKeyset(name string) (*fi.Keyset, error) {

View File

@ -56,9 +56,9 @@ type IssueCertRequest struct {
} }
type Keystore interface { type Keystore interface {
// FindKeypair finds a cert & private key, returning nil where either is not found // FindPrimaryKeypair finds a cert & private key, returning nil where either is not found
// (if the certificate is found but not keypair, that is not an error: only the cert will be returned). // (if the certificate is found but not keypair, that is not an error: only the cert will be returned).
FindKeypair(name string) (*Certificate, *PrivateKey, error) FindPrimaryKeypair(name string) (*Certificate, *PrivateKey, error)
} }
// IssueCert issues a certificate, either a self-signed CA or from a CA in a keystore. // IssueCert issues a certificate, either a self-signed CA or from a CA in a keystore.
@ -116,7 +116,7 @@ func IssueCert(request *IssueCertRequest, keystore Keystore) (issuedCertificate
var signer *x509.Certificate var signer *x509.Certificate
if !template.IsCA { if !template.IsCA {
var err error var err error
caCertificate, caPrivateKey, err = keystore.FindKeypair(request.Signer) caCertificate, caPrivateKey, err = keystore.FindPrimaryKeypair(request.Signer)
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }

View File

@ -38,7 +38,7 @@ type mockKeystore struct {
invoked bool invoked bool
} }
func (m *mockKeystore) FindKeypair(name string) (*Certificate, *PrivateKey, error) { func (m *mockKeystore) FindPrimaryKeypair(name string) (*Certificate, *PrivateKey, error) {
assert.False(m.t, m.invoked, "invoked already") assert.False(m.t, m.invoked, "invoked already")
m.invoked = true m.invoked = true
assert.Equal(m.t, m.signer, name, "name argument") assert.Equal(m.t, m.signer, name, "name argument")

View File

@ -157,8 +157,8 @@ func (c *CertificatePool) AsString() (string, error) {
return data.String(), nil return data.String(), nil
} }
// FindKeypair is a common implementation of pki.FindKeypair. // FindPrimaryKeypair is a common implementation of pki.FindPrimaryKeypair.
func FindKeypair(c Keystore, name string) (*pki.Certificate, *pki.PrivateKey, error) { func FindPrimaryKeypair(c Keystore, name string) (*pki.Certificate, *pki.PrivateKey, error) {
keyset, err := c.FindKeyset(name) keyset, err := c.FindKeyset(name)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err

View File

@ -145,9 +145,9 @@ func FindPrimary(keyset *kops.Keyset) *kops.KeysetItem {
return primary return primary
} }
// FindKeypair implements PKI::FindKeypair // FindPrimaryKeypair implements PKI::FindPrimaryKeypair
func (c *ClientsetCAStore) FindKeypair(name string) (*pki.Certificate, *pki.PrivateKey, error) { func (c *ClientsetCAStore) FindPrimaryKeypair(name string) (*pki.Certificate, *pki.PrivateKey, error) {
return FindKeypair(c, name) return FindPrimaryKeypair(c, name)
} }
// FindKeyset implements CAStore::FindKeyset // FindKeyset implements CAStore::FindKeyset

View File

@ -216,8 +216,8 @@ func removePrivateKeyMaterial(o *kops.Keyset) *kops.Keyset {
return c return c
} }
func (c *VFSCAStore) FindKeypair(name string) (*pki.Certificate, *pki.PrivateKey, error) { func (c *VFSCAStore) FindPrimaryKeypair(name string) (*pki.Certificate, *pki.PrivateKey, error) {
return FindKeypair(c, name) return FindPrimaryKeypair(c, name)
} }
func (c *VFSCAStore) FindKeyset(id string) (*Keyset, error) { func (c *VFSCAStore) FindKeyset(id string) (*Keyset, error) {