diff --git a/acme/jws.go b/acme/jws.go index c5c496a1..96f7ae9e 100644 --- a/acme/jws.go +++ b/acme/jws.go @@ -4,11 +4,10 @@ import ( "bytes" "crypto/ecdsa" "crypto/rsa" - "errors" "fmt" "net/http" - "github.com/square/go-jose" + "github.com/letsencrypt/go-jose" ) type jws struct { @@ -16,15 +15,10 @@ type jws struct { nonces []string } -func keyAsJWK(key interface{}) *jose.JsonWebKey { - switch k := key.(type) { - case *ecdsa.PublicKey: - return &jose.JsonWebKey{Key: k, Algorithm: "EC"} - case *rsa.PublicKey: - return &jose.JsonWebKey{Key: k, Algorithm: "RSA"} - - default: - return nil +func keyAsJWK(key *ecdsa.PublicKey) jose.JsonWebKey { + return jose.JsonWebKey{ + Key: key, + Algorithm: "EC", } } @@ -58,9 +52,8 @@ func (j *jws) signContent(content []byte) (*jose.JsonWebSignature, error) { if err != nil { return nil, err } - signer.SetNonceSource(j) - signed, err := signer.Sign(content) + signed, err := signer.Sign(content, j.consumeNonce()) if err != nil { return nil, err } @@ -86,12 +79,12 @@ func (j *jws) getNonce(url string) error { return j.getNonceFromResponse(resp) } -func (j *jws) Nonce() (string, error) { +func (j *jws) consumeNonce() string { nonce := "" if len(j.nonces) == 0 { - return nonce, errors.New("No nonce available.") + return nonce } nonce, j.nonces = j.nonces[len(j.nonces)-1], j.nonces[:len(j.nonces)-1] - return nonce, nil + return nonce } diff --git a/acme/messages.go b/acme/messages.go index 857ec32a..948a86cc 100644 --- a/acme/messages.go +++ b/acme/messages.go @@ -3,7 +3,7 @@ package acme import ( "time" - "github.com/square/go-jose" + "github.com/letsencrypt/go-jose" ) type directory struct {