aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--account.go9
-rw-r--r--register.go4
2 files changed, 11 insertions, 2 deletions
diff --git a/account.go b/account.go
index d1a5af1..9831db7 100644
--- a/account.go
+++ b/account.go
@@ -3,6 +3,7 @@ package acme
import (
"crypto"
"crypto/ecdsa"
+ "crypto/elliptic"
"crypto/rand"
"crypto/rsa"
"encoding/base64"
@@ -37,6 +38,14 @@ func NewAccount(size int) (*Account, error) {
return newAccount(key)
}
+func NewAccountEC() (*Account, error) {
+ key, err := ecdsa.GenerateKey(elliptic.P384(), rand.Reader)
+ if err != nil {
+ return nil, err
+ }
+ return newAccount(key)
+}
+
func newAccount(key crypto.PrivateKey) (*Account, error) {
switch k := key.(type) {
case *rsa.PrivateKey:
diff --git a/register.go b/register.go
index c99eab1..1888fef 100644
--- a/register.go
+++ b/register.go
@@ -32,7 +32,7 @@ func (p *Provider) Register(s Signer, c Contacts) error {
if err != nil {
return err
}
- resp.Body.Close()
+ defer resp.Body.Close()
switch resp.StatusCode {
case http.StatusCreated, http.StatusConflict:
// pass on
@@ -50,7 +50,7 @@ func (p *Provider) Register(s Signer, c Contacts) error {
if err != nil {
return err
}
- resp.Body.Close()
+ defer resp.Body.Close()
return nil
}