From 192235cb82b38862f3a53d7fb0100b17a17eb14c Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Tue, 15 Dec 2015 18:42:19 +0100 Subject: Add altname patcher --- acme.toml | 2 -- cmd/acmed/config.go | 11 +++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/acme.toml b/acme.toml index 3dbd769..5854a7d 100644 --- a/acme.toml +++ b/acme.toml @@ -43,8 +43,6 @@ hooks = [ "nginx" ] # short example, uses defaults [desire.net] -provider = "les" -account = "webmaster" altnames = [ "www.example.net" ] # www implies altname without www key = "private/www_example_net.key" cert = "certs/www_example_net.pem" diff --git a/cmd/acmed/config.go b/cmd/acmed/config.go index fede62c..cc95557 100644 --- a/cmd/acmed/config.go +++ b/cmd/acmed/config.go @@ -4,6 +4,7 @@ import ( "crypto/rsa" "errors" "path" + "strings" "github.com/BurntSushi/toml" ) @@ -60,6 +61,7 @@ var ( errNoAccount = errors.New("no account specified") errNoKey = errors.New("no key specified") errNoCert = errors.New("no cert specified") + errNoAltNames = errors.New("no altnames specified") ) func LoadConfig(fname string) (*Config, error) { @@ -114,6 +116,15 @@ func LoadConfig(fname string) (*Config, error) { v.Key = path.Join(c.Defaults.Basedir, v.Key) v.Cert = path.Join(c.Defaults.Basedir, v.Cert) } + switch len(v.Altnames) { + case 0: + return nil, errNoAltNames + case 1: + an := v.Altnames[0] + if strings.HasPrefix(an, "www.") { + v.Altnames = append(v.Altnames, an[4:]) + } + } c.Desire[k] = v } return c, nil -- cgit v1.2.3