2018-10-05 21:48:36 +00:00
|
|
|
package authority
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/pkg/errors"
|
2019-03-06 23:00:23 +00:00
|
|
|
"github.com/smallstep/certificates/authority/provisioner"
|
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) {
|
2019-03-06 23:00:23 +00:00
|
|
|
key, ok := a.provisioners.LoadEncryptedKey(kid)
|
2018-10-05 21:48:36 +00:00
|
|
|
if !ok {
|
|
|
|
return "", &apiError{errors.Errorf("encrypted key with kid %s was not found", kid),
|
|
|
|
http.StatusNotFound, context{}}
|
|
|
|
}
|
|
|
|
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) {
|
2019-03-06 23:00:23 +00:00
|
|
|
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
|
|
|
}
|