aboutsummaryrefslogtreecommitdiff
path: root/account.go
diff options
context:
space:
mode:
Diffstat (limited to 'account.go')
-rw-r--r--account.go20
1 files changed, 18 insertions, 2 deletions
diff --git a/account.go b/account.go
index 46cc88c..34040d6 100644
--- a/account.go
+++ b/account.go
@@ -2,6 +2,7 @@ package acme
import (
"crypto"
+ "crypto/rand"
"crypto/rsa"
"encoding/base64"
"encoding/json"
@@ -21,8 +22,23 @@ type Account struct {
nonce chan string
}
-// NewAccount ...
-func NewAccount(key *rsa.PrivateKey) (*Account, error) {
+func LoadAccount(fname string) (*Account, error) {
+ key, err := LoadKeyFile(fname)
+ if err != nil {
+ return nil, err
+ }
+ return newAccount(key)
+}
+
+func NewAccount(size int) (*Account, error) {
+ key, err := rsa.GenerateKey(rand.Reader, size)
+ if err != nil {
+ return nil, err
+ }
+ return newAccount(key)
+}
+
+func newAccount(key *rsa.PrivateKey) (*Account, error) {
signer, err := jose.NewSigner(jose.RS256, key)
if err != nil {
return nil, err