@@ -54,10 +54,6 @@ func runACME(listenAddr string, m http.Handler) error {
54
54
altTLSALPNPort = p
55
55
}
56
56
57
- // FIXME: this path is not right, it uses "AppWorkPath" incorrectly, and writes the data into "AppWorkPath/https"
58
- // Ideally it should migrate to AppDataPath write to "AppDataPath/https"
59
- certmagic .Default .Storage = & certmagic.FileStorage {Path : setting .AcmeLiveDirectory }
60
- magic := certmagic .NewDefault ()
61
57
// Try to use private CA root if provided, otherwise defaults to system's trust
62
58
var certPool * x509.CertPool
63
59
if setting .AcmeCARoot != "" {
@@ -67,7 +63,13 @@ func runACME(listenAddr string, m http.Handler) error {
67
63
log .Warn ("Failed to parse CA Root certificate, using default CA trust: %v" , err )
68
64
}
69
65
}
70
- myACME := certmagic .NewACMEIssuer (magic , certmagic.ACMEIssuer {
66
+ // FIXME: this path is not right, it uses "AppWorkPath" incorrectly, and writes the data into "AppWorkPath/https"
67
+ // Ideally it should migrate to AppDataPath write to "AppDataPath/https"
68
+ // And one more thing, no idea why we should set the global default variables here
69
+ // But it seems that the current ACME code needs these global variables to make renew work.
70
+ // Otherwise, "renew" will use incorrect storage path
71
+ certmagic .Default .Storage = & certmagic.FileStorage {Path : setting .AcmeLiveDirectory }
72
+ certmagic .DefaultACME = certmagic.ACMEIssuer {
71
73
CA : setting .AcmeURL ,
72
74
TrustedRoots : certPool ,
73
75
Email : setting .AcmeEmail ,
@@ -77,8 +79,10 @@ func runACME(listenAddr string, m http.Handler) error {
77
79
ListenHost : setting .HTTPAddr ,
78
80
AltTLSALPNPort : altTLSALPNPort ,
79
81
AltHTTPPort : altHTTPPort ,
80
- })
82
+ }
81
83
84
+ magic := certmagic .NewDefault ()
85
+ myACME := certmagic .NewACMEIssuer (magic , certmagic .DefaultACME )
82
86
magic .Issuers = []certmagic.Issuer {myACME }
83
87
84
88
// this obtains certificates or renews them if necessary
0 commit comments