aboutsummaryrefslogtreecommitdiff
path: root/account.go
diff options
context:
space:
mode:
Diffstat (limited to 'account.go')
-rw-r--r--account.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/account.go b/account.go
index 0ce0643..a914db4 100644
--- a/account.go
+++ b/account.go
@@ -1,7 +1,9 @@
package acme
import (
+ "crypto"
"crypto/rsa"
+ "encoding/base64"
"io"
"net/mail"
"strings"
@@ -48,6 +50,7 @@ func (a *Account) AddPhone(phone string) error {
// Signer describes a signing interface
type Signer interface {
Sign([]byte, jose.NonceSource) (io.Reader, error)
+ Thumb(string) (string, error)
}
// Sign implements Signer interface
@@ -59,3 +62,12 @@ func (a *Account) Sign(msg []byte, n jose.NonceSource) (io.Reader, error) {
}
return strings.NewReader(obj.FullSerialize()), nil
}
+
+func (a *Account) Thumb(token string) (string, error) {
+ k := &jose.JsonWebKey{Key: a.PrivKey.Public(), Algorithm: "RSA"}
+ thumb, err := k.Thumbprint(crypto.SHA256)
+ if err != nil {
+ return "", err
+ }
+ return token + "." + base64.RawURLEncoding.EncodeToString(thumb), nil
+}