certificates/authority/provisioners.go

44 lines
1.4 KiB
Go
Raw Normal View History

2018-10-05 21:48:36 +00:00
package authority
import (
"crypto/x509"
2018-10-05 21:48:36 +00:00
"github.com/smallstep/certificates/authority/provisioner"
2020-01-24 06:04:34 +00:00
"github.com/smallstep/certificates/errs"
2018-10-05 21:48:36 +00:00
)
// GetEncryptedKey returns the JWE key corresponding to the given kid argument.
func (a *Authority) GetEncryptedKey(kid string) (string, error) {
key, ok := a.provisioners.LoadEncryptedKey(kid)
2018-10-05 21:48:36 +00:00
if !ok {
2020-01-24 06:04:34 +00:00
return "", errs.NotFound("encrypted key with kid %s was not found", kid)
2018-10-05 21:48:36 +00:00
}
return key, nil
}
// GetProvisioners returns a map listing each provisioner and the JWK Key Set
// with their public keys.
2019-03-07 21:07:39 +00:00
func (a *Authority) GetProvisioners(cursor string, limit int) (provisioner.List, string, error) {
provisioners, nextCursor := a.provisioners.Find(cursor, limit)
2018-10-26 01:53:13 +00:00
return provisioners, nextCursor, nil
2018-10-05 21:48:36 +00:00
}
// LoadProvisionerByCertificate returns an interface to the provisioner that
// provisioned the certificate.
func (a *Authority) LoadProvisionerByCertificate(crt *x509.Certificate) (provisioner.Interface, error) {
p, ok := a.provisioners.LoadByCertificate(crt)
if !ok {
2020-01-24 06:04:34 +00:00
return nil, errs.NotFound("provisioner not found")
}
return p, nil
}
2019-05-27 00:41:10 +00:00
// LoadProvisionerByID returns an interface to the provisioner with the given ID.
func (a *Authority) LoadProvisionerByID(id string) (provisioner.Interface, error) {
p, ok := a.provisioners.Load(id)
if !ok {
2020-01-24 06:04:34 +00:00
return nil, errs.NotFound("provisioner not found")
2019-05-27 00:41:10 +00:00
}
return p, nil
}