aboutsummaryrefslogtreecommitdiff
path: root/account.go
diff options
context:
space:
mode:
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
+}