From 03d9f3e51cf2029057987c9e5acd432924f4ea51 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Mon, 29 Feb 2016 09:30:13 +0100 Subject: Populate keyfile, if not specified --- cmd/acme/config.go | 13 ++++++++++--- cmd/acme/dim13.yml | 10 ++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/cmd/acme/config.go b/cmd/acme/config.go index 102eb0c..e099b82 100644 --- a/cmd/acme/config.go +++ b/cmd/acme/config.go @@ -118,17 +118,20 @@ func LoadConfig(fname string) (*Config, error) { if dom.KeySize == 0 { dom.KeySize = c.KeySize } + if len(dom.Altnames) == 0 { + return nil, errNoAltNames + } + dom.Altnames = checkWWW(dom.Altnames) if dom.KeyFile == "" { - return nil, errNoKey + dom.KeyFile = replace(dom.Altnames[0]) + ".pem" } if dom.CrtFile == "" { - return nil, errNoCrt + dom.CrtFile = replace(dom.Altnames[0]) + ".pem" } if c.BaseDir != "" { dom.KeyFile = path.Join(c.BaseDir, dom.KeyFile) dom.CrtFile = path.Join(c.BaseDir, dom.CrtFile) } - dom.Altnames = checkWWW(dom.Altnames) acc.Domain[i] = dom } } @@ -137,6 +140,10 @@ func LoadConfig(fname string) (*Config, error) { return c, nil } +func replace(s string) string { + return strings.Replace(s, ".", "_", -1) +} + func checkWWW(altnames []string) []string { ch := make(chan string) go func(ch chan string, s []string) { diff --git a/cmd/acme/dim13.yml b/cmd/acme/dim13.yml index 9f34d0c..7dc80a4 100644 --- a/cmd/acme/dim13.yml +++ b/cmd/acme/dim13.yml @@ -5,28 +5,22 @@ basedir: ~/.acme provider: - account: - mail: postmaster@dim13.org - keyfile: private/postmaster.key + keyfile: postmaster.key domain: - altnames: - mail.dim13.org - smtp.dim13.org - imap.dim13.org - keyfile: private/mail_dim13_org.key - crtfile: certs/mail_dim13_org.pem hook: [ dovecot, smtpd ] - mail: webmaster@dim13.org - keyfile: private/webmaster.key + keyfile: webmaster.key domain: - altnames: - www.dim13.org - keyfile: private/www_dim13_org.key - crtfile: certs/www_dim13_org.pem hook: [ nginx ] - altnames: - git.dim13.org - cvs.dim13.org - keyfile: private/wiki_dim13_org.key - crtfile: certs/wiki_dim13_org.pem hook: nginx: /etc/rc.d/nginx restart -- cgit v1.2.3