mirror of https://github.com/certd/certd
fix: 修复商用证书上传第二次运行无法使用pfx格式证书的bug
parent
b9f3dc65e0
commit
251dd1fe45
|
@ -194,4 +194,13 @@ cert.jks:jks格式证书文件,java服务器使用
|
||||||
};
|
};
|
||||||
return newCert;
|
return newCert;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async readLastCert(): Promise<CertReader | undefined> {
|
||||||
|
const cert = this.lastStatus?.status?.output?.cert;
|
||||||
|
if (cert == null) {
|
||||||
|
this.logger.info("没有找到上次的证书");
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return new CertReader(cert);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,15 +130,6 @@ export abstract class CertApplyBasePlugin extends CertApplyBaseConvertPlugin {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async readLastCert(): Promise<CertReader | undefined> {
|
|
||||||
const cert = this.lastStatus?.status?.output?.cert;
|
|
||||||
if (cert == null) {
|
|
||||||
this.logger.info("没有找到上次的证书");
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return new CertReader(cert);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查是否过期,默认提前35天
|
* 检查是否过期,默认提前35天
|
||||||
* @param expires
|
* @param expires
|
||||||
|
|
|
@ -100,8 +100,17 @@ export class CertApplyUploadPlugin extends CertApplyBaseConvertPlugin {
|
||||||
async onInit(): Promise<void> {}
|
async onInit(): Promise<void> {}
|
||||||
|
|
||||||
async getCertFromStore() {
|
async getCertFromStore() {
|
||||||
const certReader = new CertReader(this.uploadCert);
|
let certReader = null;
|
||||||
if (!certReader.expires && certReader.expires < new Date().getTime()) {
|
try {
|
||||||
|
this.logger.info("读取上次证书");
|
||||||
|
certReader = await this.readLastCert();
|
||||||
|
} catch (e) {
|
||||||
|
this.logger.warn("读取cert失败:", e);
|
||||||
|
}
|
||||||
|
if (certReader == null) {
|
||||||
|
certReader = new CertReader(this.uploadCert);
|
||||||
|
}
|
||||||
|
if (!certReader.expires || certReader.expires < new Date().getTime()) {
|
||||||
throw new Error("证书已过期,停止部署,请重新上传证书");
|
throw new Error("证书已过期,停止部署,请重新上传证书");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue