Move back to square/go-jose (reverted from commit cae6d59e19)

This commit is contained in:
xenolf 2015-11-18 21:15:49 +01:00
parent cae6d59e19
commit a8c2a12871
2 changed files with 10 additions and 17 deletions

View file

@ -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
}

View file

@ -3,7 +3,7 @@ package acme
import (
"time"
"github.com/square/go-jose"
"github.com/letsencrypt/go-jose"
)
type directory struct {