mirror of
https://github.com/caddyserver/caddy.git
synced 2025-02-24 16:59:00 +01:00
tls: Couple of quick fixes for 4d18587192
This commit is contained in:
parent
4d18587192
commit
217419f6d9
2 changed files with 10 additions and 5 deletions
|
@ -318,6 +318,9 @@ func (app *App) createAutomationPolicy(ctx caddy.Context) error {
|
||||||
// if it has an ACME issuer, maybe we can just use that
|
// if it has an ACME issuer, maybe we can just use that
|
||||||
acmeIssuer, _ = matchingPolicy.Issuer.(*caddytls.ACMEIssuer)
|
acmeIssuer, _ = matchingPolicy.Issuer.(*caddytls.ACMEIssuer)
|
||||||
}
|
}
|
||||||
|
if acmeIssuer == nil {
|
||||||
|
acmeIssuer = new(caddytls.ACMEIssuer)
|
||||||
|
}
|
||||||
if acmeIssuer.Challenges == nil {
|
if acmeIssuer.Challenges == nil {
|
||||||
acmeIssuer.Challenges = new(caddytls.ChallengesConfig)
|
acmeIssuer.Challenges = new(caddytls.ChallengesConfig)
|
||||||
}
|
}
|
||||||
|
|
|
@ -678,13 +678,14 @@ const automateKey = "automate"
|
||||||
func (t *TLS) moveCertificates() error {
|
func (t *TLS) moveCertificates() error {
|
||||||
log := t.logger.Named("automigrate")
|
log := t.logger.Named("automigrate")
|
||||||
|
|
||||||
oldAcmeDir := filepath.Join(caddy.AppDataDir(), "acme")
|
baseDir := caddy.AppDataDir()
|
||||||
|
|
||||||
// if custom storage path was defined, use that instead
|
// if custom storage path was defined, use that instead
|
||||||
if fs, ok := t.ctx.Storage().(*certmagic.FileStorage); ok {
|
if fs, ok := t.ctx.Storage().(*certmagic.FileStorage); ok && fs.Path != "" {
|
||||||
oldAcmeDir = fs.Path
|
baseDir = fs.Path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
oldAcmeDir := filepath.Join(baseDir, "acme")
|
||||||
oldAcmeCas, err := ioutil.ReadDir(oldAcmeDir)
|
oldAcmeCas, err := ioutil.ReadDir(oldAcmeDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
|
@ -705,10 +706,11 @@ func (t *TLS) moveCertificates() error {
|
||||||
for _, oldCA := range oldCANames {
|
for _, oldCA := range oldCANames {
|
||||||
// make new destination path
|
// make new destination path
|
||||||
newCAName := oldCA
|
newCAName := oldCA
|
||||||
if strings.Contains(oldCA, "api.letsencrypt.org") {
|
if strings.Contains(oldCA, "api.letsencrypt.org") &&
|
||||||
|
!strings.HasSuffix(oldCA, "-directory") {
|
||||||
newCAName += "-directory"
|
newCAName += "-directory"
|
||||||
}
|
}
|
||||||
newBaseDir := filepath.Join(caddy.AppDataDir(), "certificates", newCAName)
|
newBaseDir := filepath.Join(baseDir, "certificates", newCAName)
|
||||||
err := os.MkdirAll(newBaseDir, 0700)
|
err := os.MkdirAll(newBaseDir, 0700)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("making new certs directory: %v", err)
|
return fmt.Errorf("making new certs directory: %v", err)
|
||||||
|
|
Loading…
Reference in a new issue