aboutsummaryrefslogtreecommitdiff
path: root/account.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-12-26 23:31:17 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-12-26 23:31:17 +0100
commit0c1b5b987647bb264a1027565357b1377e3f5fad (patch)
tree5c47636c824bdc30dd276db40477606b3b13cece /account.go
parenta6db8ecb747ac7ee0554c948b1ec7fdd4da290a8 (diff)
Move Thumb into Account
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
+}