aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-12-13 04:38:02 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-12-13 04:38:02 +0100
commit1db342aa4b01994cc46f5414e919dba714b1abd3 (patch)
treecd1194d3c30c052f03e1d01d5ebf9ace8940e0ae
parentc63d454264860843570c5a553e6f114c6b2e70e6 (diff)
Change singer interface
-rw-r--r--account.go8
-rw-r--r--client.go4
2 files changed, 6 insertions, 6 deletions
diff --git a/account.go b/account.go
index fffc339..8ae343b 100644
--- a/account.go
+++ b/account.go
@@ -5,8 +5,10 @@ import (
"crypto/rsa"
"encoding/json"
"fmt"
+ "io"
"io/ioutil"
"net/mail"
+ "strings"
"github.com/square/go-jose"
)
@@ -67,10 +69,10 @@ func (a Account) SaveAccount(fname string) error {
// Signer describes a signing interface
type Signer interface {
- Sign([]byte, jose.NonceSource) ([]byte, error)
+ Sign([]byte, jose.NonceSource) (io.Reader, error)
}
-func (a *Account) Sign(msg []byte, n jose.NonceSource) ([]byte, error) {
+func (a *Account) Sign(msg []byte, n jose.NonceSource) (io.Reader, error) {
if a.signer == nil {
var err error
a.signer, err = jose.NewSigner(jose.RS256, a.PrivKey)
@@ -83,7 +85,7 @@ func (a *Account) Sign(msg []byte, n jose.NonceSource) ([]byte, error) {
if err != nil {
return nil, err
}
- return []byte(obj.FullSerialize()), nil
+ return strings.NewReader(obj.FullSerialize()), nil
}
func (a *Account) ParseSigned(msg []byte) ([]byte, error) {
diff --git a/client.go b/client.go
index 40590d6..596694f 100644
--- a/client.go
+++ b/client.go
@@ -1,7 +1,6 @@
package acme
import (
- "bytes"
"encoding/json"
"errors"
"fmt"
@@ -81,8 +80,7 @@ func (c *Client) post(url string, s Signer, v interface{}) error {
return err
}
- resp, err := http.Post(url, "application/jose+json",
- bytes.NewReader(signed))
+ resp, err := http.Post(url, "application/jose+json", signed)
if err != nil {
return err
}