mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-06-06 15:47:19 +02:00
Manual Renew knows if DNS Challenge is required
This commit is contained in:
parent
8854a38f49
commit
e1b512f78f
@ -12,6 +12,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"imuslab.com/zoraxy/mod/acme"
|
||||||
"imuslab.com/zoraxy/mod/utils"
|
"imuslab.com/zoraxy/mod/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -46,6 +47,7 @@ func handleListCertificate(w http.ResponseWriter, r *http.Request) {
|
|||||||
LastModifiedDate string
|
LastModifiedDate string
|
||||||
ExpireDate string
|
ExpireDate string
|
||||||
RemainingDays int
|
RemainingDays int
|
||||||
|
DNS bool
|
||||||
}
|
}
|
||||||
|
|
||||||
results := []*CertInfo{}
|
results := []*CertInfo{}
|
||||||
@ -81,12 +83,16 @@ func handleListCertificate(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
certInfoFilename := filepath.Join(tlsCertManager.CertStore, filename+".json")
|
||||||
|
certInfo, err := acme.LoadCertInfoJSON(certInfoFilename)
|
||||||
|
SystemWideLogger.PrintAndLog("Could not Load CertInfoJson", certFilepath, err)
|
||||||
|
|
||||||
thisCertInfo := CertInfo{
|
thisCertInfo := CertInfo{
|
||||||
Domain: filename,
|
Domain: filename,
|
||||||
LastModifiedDate: modifiedTime,
|
LastModifiedDate: modifiedTime,
|
||||||
ExpireDate: certExpireTime,
|
ExpireDate: certExpireTime,
|
||||||
RemainingDays: expiredIn,
|
RemainingDays: expiredIn,
|
||||||
|
DNS: certInfo.DNS,
|
||||||
}
|
}
|
||||||
|
|
||||||
results = append(results, &thisCertInfo)
|
results = append(results, &thisCertInfo)
|
||||||
|
@ -470,7 +470,7 @@ func IsPortInUse(port int) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load cert information from json file
|
// Load cert information from json file
|
||||||
func loadCertInfoJSON(filename string) (*CertificateInfoJSON, error) {
|
func LoadCertInfoJSON(filename string) (*CertificateInfoJSON, error) {
|
||||||
certInfoBytes, err := os.ReadFile(filename)
|
certInfoBytes, err := os.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -344,7 +344,7 @@ func (a *AutoRenewer) renewExpiredDomains(certs []*ExpiredCerts) ([]string, erro
|
|||||||
|
|
||||||
// Load certificate info for ACME detail
|
// Load certificate info for ACME detail
|
||||||
certInfoFilename := fmt.Sprintf("%s/%s.json", filepath.Dir(expiredCert.Filepath), certName)
|
certInfoFilename := fmt.Sprintf("%s/%s.json", filepath.Dir(expiredCert.Filepath), certName)
|
||||||
certInfo, err := loadCertInfoJSON(certInfoFilename)
|
certInfo, err := LoadCertInfoJSON(certInfoFilename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Renew %s certificate error, can't get the ACME detail for cert: %v, trying org section as ca", certName, err)
|
log.Printf("Renew %s certificate error, can't get the ACME detail for cert: %v, trying org section as ca", certName, err)
|
||||||
|
|
||||||
|
@ -66,6 +66,7 @@
|
|||||||
<tr><th>Domain</th>
|
<tr><th>Domain</th>
|
||||||
<th>Last Update</th>
|
<th>Last Update</th>
|
||||||
<th>Expire At</th>
|
<th>Expire At</th>
|
||||||
|
<th>DNS Challenge</th>
|
||||||
<th class="no-sort">Renew</th>
|
<th class="no-sort">Renew</th>
|
||||||
<th class="no-sort">Remove</th>
|
<th class="no-sort">Remove</th>
|
||||||
</tr></thead>
|
</tr></thead>
|
||||||
@ -147,7 +148,7 @@
|
|||||||
|
|
||||||
|
|
||||||
//Renew certificate by button press
|
//Renew certificate by button press
|
||||||
function renewCertificate(domain, btn=undefined){
|
function renewCertificate(domain, dns, btn=undefined){
|
||||||
let defaultCA = $("#defaultCA").dropdown("get value");
|
let defaultCA = $("#defaultCA").dropdown("get value");
|
||||||
if (defaultCA.trim() == ""){
|
if (defaultCA.trim() == ""){
|
||||||
defaultCA = "Let's Encrypt";
|
defaultCA = "Let's Encrypt";
|
||||||
@ -160,7 +161,7 @@
|
|||||||
$(btn).addClass('disabled');
|
$(btn).addClass('disabled');
|
||||||
$(btn).html(`<i class="ui loading spinner icon"></i>`);
|
$(btn).html(`<i class="ui loading spinner icon"></i>`);
|
||||||
}
|
}
|
||||||
obtainCertificate(domain, defaultCA.trim(), function(succ){
|
obtainCertificate(domain, dns, defaultCA.trim(), function(succ){
|
||||||
if (btn != undefined){
|
if (btn != undefined){
|
||||||
$(btn).removeClass('disabled');
|
$(btn).removeClass('disabled');
|
||||||
if (succ){
|
if (succ){
|
||||||
@ -181,7 +182,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Obtain certificate from API, only support one domain
|
// Obtain certificate from API, only support one domain
|
||||||
function obtainCertificate(domains, usingCa = "Let's Encrypt", callback=undefined) {
|
function obtainCertificate(domains, dns, usingCa = "Let's Encrypt", callback=undefined) {
|
||||||
//Load the ACME email from server side
|
//Load the ACME email from server side
|
||||||
let acmeEmail = "";
|
let acmeEmail = "";
|
||||||
$.get("/api/acme/autoRenew/email", function(data){
|
$.get("/api/acme/autoRenew/email", function(data){
|
||||||
@ -213,6 +214,8 @@
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//Filename cannot contain wildcards, and wildcards are possible with DNS challenges
|
||||||
|
filename = filename.replace("*", "_");
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/api/acme/obtainCert",
|
url: "/api/acme/obtainCert",
|
||||||
@ -222,6 +225,7 @@
|
|||||||
filename: filename,
|
filename: filename,
|
||||||
email: email,
|
email: email,
|
||||||
ca: usingCa,
|
ca: usingCa,
|
||||||
|
dns: dns
|
||||||
},
|
},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
if (response.error) {
|
if (response.error) {
|
||||||
@ -357,7 +361,8 @@
|
|||||||
<td>${entry.Domain}</td>
|
<td>${entry.Domain}</td>
|
||||||
<td>${entry.LastModifiedDate}</td>
|
<td>${entry.LastModifiedDate}</td>
|
||||||
<td class="${isExpired?"expired":"valid"} certdate">${entry.ExpireDate} (${!isExpired?entry.RemainingDays+" days left":"Expired"})</td>
|
<td class="${isExpired?"expired":"valid"} certdate">${entry.ExpireDate} (${!isExpired?entry.RemainingDays+" days left":"Expired"})</td>
|
||||||
<td><button title="Renew Certificate" class="ui mini basic icon button renewButton" onclick="renewCertificate('${entry.Domain}', this);"><i class="ui green refresh icon"></i></button></td>
|
<td><i class="${entry.DNS?"green check": "red times"} circle outline icon"></i></td>
|
||||||
|
<td><button title="Renew Certificate" class="ui mini basic icon button renewButton" onclick="renewCertificate('${entry.Domain}', '${entry.DNS}', this);"><i class="ui green refresh icon"></i></button></td>
|
||||||
<td><button title="Delete key-pair" class="ui mini basic red icon button" onclick="deleteCertificate('${entry.Domain}');"><i class="ui red trash icon"></i></button></td>
|
<td><button title="Delete key-pair" class="ui mini basic red icon button" onclick="deleteCertificate('${entry.Domain}');"><i class="ui red trash icon"></i></button></td>
|
||||||
</tr>`);
|
</tr>`);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user