mirror of
https://github.com/certd/certd.git
synced 2026-04-14 20:40:53 +08:00
refactor: huawei
This commit is contained in:
@@ -123,12 +123,17 @@ export class AcmeService {
|
||||
|
||||
/* Replace this */
|
||||
this.logger.info(`Would remove TXT record "${dnsRecord}" with value "${recordValue}"`);
|
||||
await dnsProvider.removeRecord({
|
||||
fullRecord: dnsRecord,
|
||||
type: "TXT",
|
||||
value: keyAuthorization,
|
||||
record: recordItem,
|
||||
});
|
||||
try {
|
||||
await dnsProvider.removeRecord({
|
||||
fullRecord: dnsRecord,
|
||||
type: "TXT",
|
||||
value: keyAuthorization,
|
||||
record: recordItem,
|
||||
});
|
||||
} catch (e) {
|
||||
this.logger.error("删除解析记录出错:", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -181,6 +181,17 @@ export class CertApplyPlugin implements ITaskPlugin {
|
||||
if (this.forceUpdate) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let inputChanged = false;
|
||||
const inputCacheKey = "input.cert";
|
||||
const oldInputStr = await this.pipelineContext.get(inputCacheKey);
|
||||
await this.pipelineContext.set(inputCacheKey, this.cert);
|
||||
const oldInput = JSON.stringify(oldInputStr);
|
||||
const thisInput = JSON.stringify(this.cert);
|
||||
if (oldInput !== thisInput) {
|
||||
inputChanged = true;
|
||||
}
|
||||
|
||||
let oldCert;
|
||||
try {
|
||||
oldCert = await this.readCurrentCert();
|
||||
@@ -192,6 +203,11 @@ export class CertApplyPlugin implements ITaskPlugin {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (inputChanged) {
|
||||
this.logger.info("输入参数变更,申请新证书");
|
||||
return null;
|
||||
}
|
||||
|
||||
const ret = this.isWillExpire(oldCert.expires, this.renewDays);
|
||||
if (!ret.isWillExpire) {
|
||||
this.logger.info(`证书还未过期:过期时间${dayjs(oldCert.expires).format("YYYY-MM-DD HH:mm:ss")},剩余${ret.leftDays}天`);
|
||||
@@ -261,6 +277,9 @@ export class CertApplyPlugin implements ITaskPlugin {
|
||||
csr: this.formatCert(cert.csr),
|
||||
};
|
||||
await this.pipelineContext.set("cert", newCert);
|
||||
await this.pipelineContext.set("cert.crt", newCert.crt);
|
||||
await this.pipelineContext.set("cert.key", newCert.key);
|
||||
await this.pipelineContext.set("cert.csr", newCert.csr);
|
||||
}
|
||||
|
||||
async readCurrentCert() {
|
||||
|
||||
Reference in New Issue
Block a user