From b0397df719b2f826b86f5df7736183512955c66c Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Fri, 11 Dec 2015 15:42:22 -0700 Subject: [PATCH] Save obtained certs even if there were failures --- caddy/letsencrypt/letsencrypt.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/caddy/letsencrypt/letsencrypt.go b/caddy/letsencrypt/letsencrypt.go index 16312bd6..8ea3bb30 100644 --- a/caddy/letsencrypt/letsencrypt.go +++ b/caddy/letsencrypt/letsencrypt.go @@ -114,6 +114,19 @@ func Activate(configs []server.Config) ([]server.Config, error) { errMsg += "[" + domain + "] failed to get certificate: " + obtainErr.Error() + "\n" } + // Save the certs we did obtain, though, before leaving + if err := saveCertsAndKeys(certificates); err == nil { + if len(certificates) > 0 { + var certList []string + for _, cert := range certificates { + certList = append(certList, cert.Domain) + } + errMsg += "Saved certificates for: " + strings.Join(certList, ", ") + "\n" + } + } else { + errMsg += "Unable to save obtained certificates: " + err.Error() + "\n" + } + return configs, errors.New(errMsg) }