fix: 修复阿里云cdn证书部署失败问题,增加certname参数传入

- 添加证书所在地域选择功能,默认为 cn-hangzhou(杭州)
- 国际站用户可选择 ap-southeast-1(新加坡)地域
- 优化证书上传和设置流程,增加证书名称和地域参数
pull/373/head
xiaojunnuo 2025-04-12 23:58:38 +08:00
parent 9c4cbe17a2
commit 965dc2cb47
1 changed files with 24 additions and 2 deletions

View File

@ -68,12 +68,29 @@ export class DeployCertToAliyunCDN extends AbstractTaskPlugin {
) )
domainName!: string | string[]; domainName!: string | string[];
@TaskInput({
title: '证书所在地域',
helper: 'cn-hangzhou和ap-southeast-1默认cn-hangzhou。国际站用户建议使用ap-southeast-1。',
value:"cn-hangzhou",
component: {
name: 'a-select',
options:[
{value:'cn-hangzhou',label:'中国大陆'},
{value:'ap-southeast-1',label:'新加坡'}
]
},
required: true,
})
certRegion:string
@TaskInput({ @TaskInput({
title: '证书名称', title: '证书名称',
helper: '上传后将以此名称作为前缀备注', helper: '上传后将以此名称作为前缀备注',
}) })
certName!: string; certName!: string;
async onInstance() {} async onInstance() {}
async execute(): Promise<void> { async execute(): Promise<void> {
this.logger.info('开始部署证书到阿里云cdn'); this.logger.info('开始部署证书到阿里云cdn');
@ -89,9 +106,12 @@ export class DeployCertToAliyunCDN extends AbstractTaskPlugin {
} }
let certId: any = this.cert; let certId: any = this.cert;
const certName = this.appendTimeSuffix(this.certName);
if (typeof this.cert === 'object') { if (typeof this.cert === 'object') {
certId = await sslClient.uploadCert({ certId = await sslClient.uploadCert({
name: this.appendTimeSuffix(this.certName), name:certName,
cert: this.cert, cert: this.cert,
}); });
} }
@ -105,6 +125,8 @@ export class DeployCertToAliyunCDN extends AbstractTaskPlugin {
await this.SetCdnDomainSSLCertificate(client, { await this.SetCdnDomainSSLCertificate(client, {
CertId: certId, CertId: certId,
DomainName: domain, DomainName: domain,
CertName: certName,
CertRegion:this.certRegion || 'cn-hangzhou',
}); });
} }
@ -122,7 +144,7 @@ export class DeployCertToAliyunCDN extends AbstractTaskPlugin {
return client; return client;
} }
async SetCdnDomainSSLCertificate(client: any, params: { CertId: number; DomainName: string }) { async SetCdnDomainSSLCertificate(client: any, params: { CertId: number; DomainName: string,CertName:string,CertRegion:string }) {
const requestOption = { const requestOption = {
method: 'POST', method: 'POST',
formatParams: false, formatParams: false,