From 1c2bc6bef2393ad48b743e2bb69c8930cc6226e7 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Tue, 15 Dec 2015 18:56:42 +0100 Subject: Strip down NewAccount --- account.go | 17 +++++++++++------ acme.toml | 1 - cmd/acmed/main.go | 8 ++++++++ 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) + } + } -- cgit v1.2.3