summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2020-03-07 11:47:55 -0700
committerMatthew Holt <[email protected]>2020-03-07 11:47:55 -0700
commit217419f6d97885daf0fb8832a407626e578523f0 (patch)
treee3fd05343ae5eb1c74a6cf171503d5957cf0d466
parent4d18587192e4fffe5b34b714eaabcfc212914c1e (diff)
downloadcaddy-217419f6d97885daf0fb8832a407626e578523f0.tar.gz
caddy-217419f6d97885daf0fb8832a407626e578523f0.zip
tls: Couple of quick fixes for 4d18587192e4fffe5b34b714eaabcfc212914c1e
-rw-r--r--modules/caddyhttp/autohttps.go3
-rw-r--r--modules/caddytls/tls.go12
2 files changed, 10 insertions, 5 deletions
diff --git a/modules/caddyhttp/autohttps.go b/modules/caddyhttp/autohttps.go
index 6b53d39ef..751c6dfd4 100644
--- a/modules/caddyhttp/autohttps.go
+++ b/modules/caddyhttp/autohttps.go
@@ -318,6 +318,9 @@ func (app *App) createAutomationPolicy(ctx caddy.Context) error {
// if it has an ACME issuer, maybe we can just use that
acmeIssuer, _ = matchingPolicy.Issuer.(*caddytls.ACMEIssuer)
}
+ if acmeIssuer == nil {
+ acmeIssuer = new(caddytls.ACMEIssuer)
+ }
if acmeIssuer.Challenges == nil {
acmeIssuer.Challenges = new(caddytls.ChallengesConfig)
}
diff --git a/modules/caddytls/tls.go b/modules/caddytls/tls.go
index a7cd54e56..4fa126e34 100644
--- a/modules/caddytls/tls.go
+++ b/modules/caddytls/tls.go
@@ -678,13 +678,14 @@ const automateKey = "automate"
func (t *TLS) moveCertificates() error {
log := t.logger.Named("automigrate")
- oldAcmeDir := filepath.Join(caddy.AppDataDir(), "acme")
+ baseDir := caddy.AppDataDir()
// if custom storage path was defined, use that instead
- if fs, ok := t.ctx.Storage().(*certmagic.FileStorage); ok {
- oldAcmeDir = fs.Path
+ if fs, ok := t.ctx.Storage().(*certmagic.FileStorage); ok && fs.Path != "" {
+ baseDir = fs.Path
}
+ oldAcmeDir := filepath.Join(baseDir, "acme")
oldAcmeCas, err := ioutil.ReadDir(oldAcmeDir)
if err != nil {
if os.IsNotExist(err) {
@@ -705,10 +706,11 @@ func (t *TLS) moveCertificates() error {
for _, oldCA := range oldCANames {
// make new destination path
newCAName := oldCA
- if strings.Contains(oldCA, "api.letsencrypt.org") {
+ if strings.Contains(oldCA, "api.letsencrypt.org") &&
+ !strings.HasSuffix(oldCA, "-directory") {
newCAName += "-directory"
}
- newBaseDir := filepath.Join(caddy.AppDataDir(), "certificates", newCAName)
+ newBaseDir := filepath.Join(baseDir, "certificates", newCAName)
err := os.MkdirAll(newBaseDir, 0700)
if err != nil {
return fmt.Errorf("making new certs directory: %v", err)