From 0913f37b414e89115dd54f240fcc87354e54e21b Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Mon, 29 Feb 2016 15:53:56 +0100 Subject: Readd subdirs --- cmd/acme/config.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/cmd/acme/config.go b/cmd/acme/config.go index e099b82..bfe9fbc 100644 --- a/cmd/acme/config.go +++ b/cmd/acme/config.go @@ -3,6 +3,7 @@ package main import ( "errors" "io/ioutil" + "os" "os/user" "path" "strings" @@ -15,6 +16,8 @@ import ( const ( defKeySize = 2048 defGrace = time.Hour * 24 * 7 + keyPath = "private" + crtPath = "certs" ) type Config struct { @@ -122,11 +125,12 @@ func LoadConfig(fname string) (*Config, error) { return nil, errNoAltNames } dom.Altnames = checkWWW(dom.Altnames) + d := dom.Altnames[0] if dom.KeyFile == "" { - dom.KeyFile = replace(dom.Altnames[0]) + ".pem" + dom.KeyFile = path.Join(keyPath, replace(d)+".key") } if dom.CrtFile == "" { - dom.CrtFile = replace(dom.Altnames[0]) + ".pem" + dom.CrtFile = path.Join(crtPath, replace(d)+".crt") } if c.BaseDir != "" { dom.KeyFile = path.Join(c.BaseDir, dom.KeyFile) @@ -140,6 +144,20 @@ func LoadConfig(fname string) (*Config, error) { return c, nil } +func mkdirs(c *Config) error { + key := keyPath + crt := crtPath + if c.BaseDir != "" { + key = path.Join(c.BaseDir, keyPath) + crt = path.Join(c.BaseDir, crtPath) + } + err := os.MkdirAll(key, 0700) + if err != nil { + return err + } + return os.MkdirAll(crt, 0755) +} + func replace(s string) string { return strings.Replace(s, ".", "_", -1) } -- cgit v1.2.3