@marcel91200 / caddy Mirror · read-only / commits / 217419f6
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 14, 05:15 UTC

tls: Couple of quick fixes for 4d18587192e4fffe5b34b714eaabcfc212914c1e

Matthew Holt committed Mar 7, 2020 at 11:47 UTC 217419f6d97885daf0fb8832a407626e578523f0
2 files changed +10 -5
modules/caddyhttp/autohttps.go
+3
@@ -318,6 +318,9 @@ func (app *App) createAutomationPolicy(ctx caddy.Context) error {
318 // if it has an ACME issuer, maybe we can just use that
319 acmeIssuer, _ = matchingPolicy.Issuer.(*caddytls.ACMEIssuer)
320 }
321 + if acmeIssuer == nil {
322 + acmeIssuer = new(caddytls.ACMEIssuer)
323 + }
324 if acmeIssuer.Challenges == nil {
325 acmeIssuer.Challenges = new(caddytls.ChallengesConfig)
326 }
modules/caddytls/tls.go
+7 -5
@@ -678,13 +678,14 @@ const automateKey = "automate"
678 func (t *TLS) moveCertificates() error {
679 log := t.logger.Named("automigrate")
680
681 - oldAcmeDir := filepath.Join(caddy.AppDataDir(), "acme")
681 + baseDir := caddy.AppDataDir()
682
683 // if custom storage path was defined, use that instead
684 - if fs, ok := t.ctx.Storage().(*certmagic.FileStorage); ok {
685 - oldAcmeDir = fs.Path
684 + if fs, ok := t.ctx.Storage().(*certmagic.FileStorage); ok && fs.Path != "" {
685 + baseDir = fs.Path
686 }
687
688 + oldAcmeDir := filepath.Join(baseDir, "acme")
689 oldAcmeCas, err := ioutil.ReadDir(oldAcmeDir)
690 if err != nil {
691 if os.IsNotExist(err) {
@@ -705,10 +706,11 @@ func (t *TLS) moveCertificates() error {
706 for _, oldCA := range oldCANames {
707 // make new destination path
708 newCAName := oldCA
708 - if strings.Contains(oldCA, "api.letsencrypt.org") {
709 + if strings.Contains(oldCA, "api.letsencrypt.org") &&
710 + !strings.HasSuffix(oldCA, "-directory") {
711 newCAName += "-directory"
712 }
711 - newBaseDir := filepath.Join(caddy.AppDataDir(), "certificates", newCAName)
713 + newBaseDir := filepath.Join(baseDir, "certificates", newCAName)
714 err := os.MkdirAll(newBaseDir, 0700)
715 if err != nil {
716 return fmt.Errorf("making new certs directory: %v", err)