perf: esa 自动删除过期证书提示

v2-dev
xiaojunnuo 2025-10-22 23:07:33 +08:00
parent 911e69e3bc
commit 8bf1f828b9
1 changed files with 21 additions and 14 deletions

View File

@ -12,7 +12,7 @@ import {
title: "阿里云-部署至ESA",
icon: "svg:icon-aliyun",
group: pluginGroups.aliyun.key,
desc: "部署证书到阿里云ESA(边缘安全加速)",
desc: "部署证书到阿里云ESA(边缘安全加速),自动删除过期证书",
needPlus: false,
default: {
strategy: {
@ -125,6 +125,7 @@ export class AliyunDeployCertToESA extends AbstractTaskPlugin {
const { certId, certName } = await this.getAliyunCertId(access);
for (const siteId of this.siteIds) {
try {
const res = await client.doRequest({
// 接口名称
@ -159,6 +160,7 @@ export class AliyunDeployCertToESA extends AbstractTaskPlugin {
}
}
async getClient(access: AliyunAccess) {
const endpoint = `esa.${this.regionId}.aliyuncs.com`;
return access.getClient(endpoint);
@ -211,6 +213,7 @@ export class AliyunDeployCertToESA extends AbstractTaskPlugin {
this.logger.info(`证书${item.Name}状态:${item.Status}`);
if (item.Status === "Expired") {
this.logger.info(`证书${item.Name}已过期,执行删除`);
try{
await client.doRequest({
action: "DeleteCertificate",
version: "2024-09-10",
@ -224,6 +227,10 @@ export class AliyunDeployCertToESA extends AbstractTaskPlugin {
}
});
this.logger.info(`证书${item.Name}已删除`);
}catch (e) {
this.logger.error(`过期证书${item.Name}删除失败:`,e.message)
}
}
}
}