aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-02-29 15:53:56 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-02-29 15:53:56 +0100
commit0913f37b414e89115dd54f240fcc87354e54e21b (patch)
tree763a17f9c281ae51a3eeec4ec395a4a81651939a
parent03d9f3e51cf2029057987c9e5acd432924f4ea51 (diff)
Readd subdirs
-rw-r--r--cmd/acme/config.go22
1 files 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)
}