aboutsummaryrefslogtreecommitdiff
path: root/account.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-11-27 14:09:12 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-11-27 14:09:12 +0100
commit6c0b2240d3d53621e0b145b1bd1b79a3826e3485 (patch)
tree218a279fe3c24c20a34d491b8746319b276edcce /account.go
parent23282f058e68aac8bf29216faf90d7f27f6ad8c8 (diff)
Add account
Diffstat (limited to 'account.go')
-rw-r--r--account.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/account.go b/account.go
new file mode 100644
index 0000000..5264636
--- /dev/null
+++ b/account.go
@@ -0,0 +1,27 @@
+package acme
+
+import (
+ "crypto/rand"
+ "crypto/rsa"
+ "net/mail"
+)
+
+type Account struct {
+ Contact []string
+ PrivKey *rsa.PrivateKey
+}
+
+func NewAccount(email string, bits int) (Account, error) {
+ m, err := mail.ParseAddress(email)
+ if err != nil {
+ return Account{}, err
+ }
+ key, err := rsa.GenerateKey(rand.Reader, bits)
+ if err != nil {
+ return Account{}, err
+ }
+ return Account{
+ Contact: []string{"mailto:" + m.Address},
+ PrivKey: key,
+ }, nil
+}