This commit is contained in:
xiaojunnuo
2025-05-26 22:44:56 +08:00
parent e08cf57b72
commit 86e521b9aa
7 changed files with 37 additions and 13 deletions

View File

@@ -93,6 +93,11 @@ export class CertReader {
return domains;
}
getAltNames() {
const { detail } = this.getCrtDetail();
return detail.domains.altNames;
}
static getMainDomain(crt: string) {
const { detail } = CertReader.readCertDetail(crt);
return detail.domains.commonName;
@@ -174,8 +179,14 @@ export class CertReader {
buildCertFileName(suffix: string, applyTime: any, prefix = "cert") {
const detail = this.getCrtDetail();
let domain = detail.detail.domains.commonName;
domain = domain.replace(".", "_").replace("*", "_");
domain = domain.replaceAll(".", "_").replaceAll("*", "_");
const timeStr = dayjs(applyTime).format("YYYYMMDDHHmmss");
return `${prefix}_${domain}_${timeStr}.${suffix}`;
}
buildCertName() {
let domain = this.getMainDomain();
domain = domain.replaceAll("*", "_").replaceAll("*", "_");
return `${domain}_${dayjs().format("YYYYMMDDHHmmssSSS")}`;
}
}

View File

@@ -83,7 +83,7 @@ export class AliyunSslClient {
method: "POST",
};
this.opts.logger.info("开始上传证书");
this.opts.logger.info(`开始上传证书${req.name}`);
const ret: any = await client.request("UploadUserCertificate", params, requestOption);
this.checkRet(ret);
this.opts.logger.info("证书上传成功aliyunCertId=", ret.CertId);

View File

@@ -50,9 +50,22 @@ export class TencentSslClient {
const ret = await client.UploadCertificate(params);
this.checkRet(ret);
this.logger.info("证书上传成功tencentCertId=", ret.CertificateId);
await this.switchCertNotify([ret.CertificateId], true);
return ret.CertificateId;
}
async switchCertNotify(certIds: string[], disabled: boolean) {
const client = await this.getSslClient();
const params = {
CertificateIds: certIds,
SwitchStatus: disabled ? 1 : 0, //1是忽略通知0是不忽略
};
const ret = await client.ModifyCertificatesExpiringNotificationSwitch(params);
this.checkRet(ret);
this.logger.info(`关闭证书${certIds}过期通知成功`);
return ret.RequestId;
}
async deployCertificateInstance(params: any) {
const client = await this.getSslClient();
const res = await client.DeployCertificateInstance(params);