aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-12-15 18:56:42 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-12-15 18:56:42 +0100
commit1c2bc6bef2393ad48b743e2bb69c8930cc6226e7 (patch)
tree41beda50a6f89f1c3766e20f2a1ab8dcc707d4e7
parent192235cb82b38862f3a53d7fb0100b17a17eb14c (diff)
Strip down NewAccount
-rw-r--r--account.go17
-rw-r--r--acme.toml1
-rw-r--r--cmd/acmed/main.go8
3 files changed, 19 insertions, 7 deletions
diff --git a/account.go b/account.go
index 6a4e123..8ab9d1c 100644
--- a/account.go
+++ b/account.go
@@ -1,7 +1,6 @@
package acme
import (
- "crypto/rand"
"crypto/rsa"
"encoding/json"
"io"
@@ -32,18 +31,24 @@ func newMail(email string) (Mail, error) {
return mm, nil
}
+func newPhone(phone string) (Phone, error) {
+ p := strings.TrimSpace(phone)
+ return Phone(p), nil
+}
+
// NewAccount ...
-func NewAccount(email string, bits int) (*Account, error) {
+func NewAccount(email, phone string, key *rsa.PrivateKey) (*Account, error) {
+ var c Contacts
m, err := newMail(email)
if err != nil {
return nil, err
}
- key, err := rsa.GenerateKey(rand.Reader, bits)
- if err != nil {
- return nil, err
+ c = append(c, m)
+ if ph, _ := newPhone(phone); ph != "" {
+ c = append(c, ph)
}
return &Account{
- Contact: Contacts{m},
+ Contact: c,
PrivKey: key,
}, nil
}
diff --git a/acme.toml b/acme.toml
index 5854a7d..936c8d9 100644
--- a/acme.toml
+++ b/acme.toml
@@ -14,7 +14,6 @@ directory = "https://acme-staging.api.letsencrypt.org/directory"
[account.webmaster]
mail = "webmaster@example.com"
-phone = "+12025551212"
key = "private/webmaster.key"
[account.postmaster]
diff --git a/cmd/acmed/main.go b/cmd/acmed/main.go
index 202fe58..11db4e2 100644
--- a/cmd/acmed/main.go
+++ b/cmd/acmed/main.go
@@ -11,6 +11,8 @@ import (
"log"
"os"
"path"
+
+ "dim13.org/acme"
)
var confName = flag.String("conf", "acme.toml", "configuration file")
@@ -73,4 +75,10 @@ func main() {
}
conf.Desire[k] = des
}
+
+ for k, des := range conf.Desire {
+ a, _ := acme.NewAccount(des.account.Mail, des.account.Phone, des.account.key)
+ log.Println(k, a)
+ }
+
}