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

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