aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-02-29 09:30:13 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-02-29 09:30:13 +0100
commit03d9f3e51cf2029057987c9e5acd432924f4ea51 (patch)
tree398e0c4d37a820b12fd11afe2b2d30951dbd0c32
parentcd25bb08f9c9f1d402a8ef77ab5910b69c24a3ad (diff)
Populate keyfile, if not specified
-rw-r--r--cmd/acme/config.go13
-rw-r--r--cmd/acme/dim13.yml10
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