From f37c6e605107764cd1fd6d3fbd3d975ea8a3b8b8 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Mon, 21 Dec 2015 01:06:12 +0100 Subject: WIP --- acme.toml | 52 ++++++++++++++++++++++++++-------------------------- client.go | 26 ++++++++++++++++++++++++-- cmd/acme/main.go | 5 ----- 3 files changed, 50 insertions(+), 33 deletions(-) diff --git a/acme.toml b/acme.toml index 13b963b..3ee1c83 100644 --- a/acme.toml +++ b/acme.toml @@ -6,8 +6,8 @@ provider = "les" account = "webmaster" size = 2048 # default key size -[provider.lev1] -directory = "https://acme-v01.api.letsencrypt.org/directory" +#[provider.lev1] +#directory = "https://acme-v01.api.letsencrypt.org/directory" [provider.les] directory = "https://acme-staging.api.letsencrypt.org/directory" @@ -16,23 +16,23 @@ directory = "https://acme-staging.api.letsencrypt.org/directory" mail = "webmaster@example.com" key = "private/webmaster.key" -[account.postmaster] -mail = "postmaster@example.com" -phone = "+12025551212" -key = "private/postmaster.key" +#[account.postmaster] +#mail = "postmaster@example.com" +#phone = "+12025551212" +#key = "private/postmaster.key" -[account.notused] -mail = "notused@example.com" -key = "private/notused.key" +#[account.notused] +#mail = "notused@example.com" +#key = "private/notused.key" [hook.nginx] cmd = "sudo service nginx reload" -[hook.dovecot] -cmd = "sudo service dovecot reload" +#[hook.dovecot] +#cmd = "sudo service dovecot reload" -[hook.smtpd] -cmd = "sudo service smtpd reload" +#[hook.smtpd] +#cmd = "sudo service smtpd reload" # long example [desire.com] @@ -45,16 +45,16 @@ webroot = "/var/www/htdocs" hooks = [ "nginx" ] # short example, uses defaults -[desire.net] -altnames = [ "www.example.net" ] # www implies altname without www -key = "private/www_example_net.key" -cert = "certs/www_example_net.pem" -hooks = [ "nginx" ] - -[desire.mail] -provider = "les" -account = "postmaster" -altnames = [ "mail.example.com" ] -key = "private/mail_example_com.key" -cert = "certs/mail_example_com.pem" -hooks = [ "dovecot", "smtpd" ] +#[desire.net] +#altnames = [ "www.example.net" ] # www implies altname without www +#key = "private/www_example_net.key" +#cert = "certs/www_example_net.pem" +#hooks = [ "nginx" ] + +#[desire.mail] +#provider = "les" +#account = "postmaster" +#altnames = [ "mail.example.com" ] +#key = "private/mail_example_com.key" +#cert = "certs/mail_example_com.pem" +#hooks = [ "dovecot", "smtpd" ] diff --git a/client.go b/client.go index 7a023b5..4737995 100644 --- a/client.go +++ b/client.go @@ -75,7 +75,7 @@ func (c *Client) post(s Signer, v interface{}) error { if err != nil { return err } - log.Println(string(body)) + log.Println("POST", string(body)) signed, err := s.Sign(body, c) if err != nil { @@ -88,6 +88,8 @@ func (c *Client) post(s Signer, v interface{}) error { } defer resp.Body.Close() c.parseHeader(resp) + log.Println("STATUS", resp.Status) + log.Println("HEADER", c) if resp.StatusCode >= http.StatusBadRequest { var p Problem @@ -168,11 +170,16 @@ func (c *Client) Register(a *Account) (*Registration, error) { // Agree to TOS func (c *Client) Agree(a *Account) (*Registration, error) { + tos := c.Link["terms-of-service"] + if tos == "" { + return nil, errors.New("TOS agreed") + } r := &Registration{ Resource: ResRegister, Contact: a.Contact, - Agreement: c.Link["terms-of-service"], + Agreement: tos, } + log.Println("TOS", tos) return r, c.post(a, r) } @@ -191,3 +198,18 @@ func (c *Client) Authorize(a *Account, domain string) (*Authorization, error) { func (c Client) String() string { return fmt.Sprintf("Location: %v Links: %v", c.Location, c.Link) } + +//////////////////////////////////////////////////////////////////////// + +// Register +// 1. new-reg +// arg: contact +// StatusCreated (201) or StatusConflict (409) +// Response: Location, Link +// 2. reg +// arg: contact, tos +// StatusOk + +// Authorize + +// Certificate diff --git a/cmd/acme/main.go b/cmd/acme/main.go index 1073e88..0606fb7 100644 --- a/cmd/acme/main.go +++ b/cmd/acme/main.go @@ -82,11 +82,6 @@ func main() { log.Fatal(err) } - log.Println(conf) - for k, des := range conf.Desire { - log.Println(k, des.account) - } - 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