chore: 阿里云上传证书返回值优化为带region的

This commit is contained in:
xiaojunnuo
2026-01-31 19:36:37 +08:00
parent 1a0d3eeb1b
commit 1089aeab9e
10 changed files with 24 additions and 20 deletions
@@ -305,11 +305,11 @@ export class AliyunDeployCertToALB extends AbstractTaskPlugin {
}); });
const certName = this.buildCertName(CertReader.getMainDomain(this.cert.crt)); const certName = this.buildCertName(CertReader.getMainDomain(this.cert.crt));
const certIdRes = await sslClient.uploadCert({ const certIdRes = await sslClient.uploadCertificate({
name: certName, name: certName,
cert: this.cert cert: this.cert
}); });
certId = certIdRes.certId; certId = certIdRes.certId as any;
} }
return certId; return certId;
@@ -155,11 +155,11 @@ export class AliyunDeployCertToAll extends AbstractTaskPlugin {
// //
let certId: any = this.cert; let certId: any = this.cert;
if (typeof this.cert === "object") { if (typeof this.cert === "object") {
const certIdRes = await sslClient.uploadCert({ const certIdRes = await sslClient.uploadCertificate({
name: this.appendTimeSuffix("certd"), name: this.appendTimeSuffix("certd"),
cert: this.cert, cert: this.cert,
}); });
certId = certIdRes.certId; certId = certIdRes.certId as any;
} }
const jobId = await this.createDeployJob(sslClient, certId); const jobId = await this.createDeployJob(sslClient, certId);
@@ -115,11 +115,11 @@ export class DeployCertToAliyunCDN extends AbstractTaskPlugin {
if (typeof this.cert === 'object') { if (typeof this.cert === 'object') {
// @ts-ignore // @ts-ignore
const certName = this.buildCertName(CertReader.getMainDomain(this.cert.crt)) const certName = this.buildCertName(CertReader.getMainDomain(this.cert.crt))
const certIdRes = await sslClient.uploadCert({ const certIdRes = await sslClient.uploadCertificate({
name:certName, name:certName,
cert: this.cert, cert: this.cert,
}); });
certId = certIdRes.certId; certId = certIdRes.certId as any;
} }
const client = await this.getClient(access); const client = await this.getClient(access);
@@ -119,11 +119,11 @@ export class AliyunDeployCertToESA extends AbstractTaskPlugin {
certName = this.buildCertName(CertReader.getMainDomain(this.cert.crt)); certName = this.buildCertName(CertReader.getMainDomain(this.cert.crt));
const certIdRes = await sslClient.uploadCert({ const certIdRes = await sslClient.uploadCertificate({
name: certName, name: certName,
cert: this.cert cert: this.cert
}); });
certId = certIdRes.certId; certId = certIdRes.certId as any;
this.logger.info("上传证书成功", certId, certName); this.logger.info("上传证书成功", certId, certName);
} }
return { return {
@@ -294,11 +294,11 @@ export class AliyunDeployCertToNLB extends AbstractTaskPlugin {
const certName = this.buildCertName(CertReader.getMainDomain(this.cert.crt)) const certName = this.buildCertName(CertReader.getMainDomain(this.cert.crt))
const certIdRes = await sslClient.uploadCert({ const certIdRes = await sslClient.uploadCertificate({
name: certName, name: certName,
cert: this.cert, cert: this.cert,
}); });
certId = certIdRes.certId; certId = certIdRes.certId as any;
} }
return certId; return certId;
} }
@@ -212,11 +212,11 @@ export class DeployCertToAliyunOSS extends AbstractTaskPlugin {
certName = this.buildCertName(CertReader.getMainDomain(this.cert.crt)); certName = this.buildCertName(CertReader.getMainDomain(this.cert.crt));
const certIdRes = await sslClient.uploadCert({ const certIdRes = await sslClient.uploadCertificate({
name: certName, name: certName,
cert: this.cert cert: this.cert
}); });
certId = certIdRes.certId; certId = certIdRes.certId as any;
this.logger.info("上传证书成功", certId, certName); this.logger.info("上传证书成功", certId, certName);
} }
return { return {
@@ -251,11 +251,11 @@ export class AliyunDeployCertToSLB extends AbstractTaskPlugin {
if (typeof this.cert === 'object') { if (typeof this.cert === 'object') {
const name = this.appendTimeSuffix('certd'); const name = this.appendTimeSuffix('certd');
const certIdRes = await sslClient.uploadCert({ const certIdRes = await sslClient.uploadCertificate({
name: name, name: name,
cert: this.cert, cert: this.cert,
}); });
certId = certIdRes.certId; certId = certIdRes.certId as any;
} }
return await sslClient.getCertInfo(certId); return await sslClient.getCertInfo(certId);
@@ -152,11 +152,11 @@ export class AliyunDeployCertToWaf extends AbstractTaskPlugin {
endpoint: this.casEndpoint, endpoint: this.casEndpoint,
}); });
const certIdRes = await sslClient.uploadCert({ const certIdRes = await sslClient.uploadCertificate({
name: this.buildCertName(CertReader.getMainDomain(this.cert.crt)), name: this.buildCertName(CertReader.getMainDomain(this.cert.crt)),
cert: this.cert, cert: this.cert,
}); });
certId = certIdRes.certId; certId = certIdRes.certId as any;
} }
const client = await this.getWafClient(access); const client = await this.getWafClient(access);
@@ -104,11 +104,11 @@ export class UploadCertToAliyun extends AbstractTaskPlugin {
}else{ }else{
certName = this.buildCertName(CertReader.getMainDomain(this.cert.crt)) certName = this.buildCertName(CertReader.getMainDomain(this.cert.crt))
} }
const certIdRes = await client.uploadCert({ const certIdRes = await client.uploadCertificate({
name: certName, name: certName,
cert: this.cert, cert: this.cert,
}); });
this.aliyunCertId = certIdRes.certId as any; this.aliyunCertId = certIdRes as any;
} }
} }
//注册插件 //注册插件
@@ -98,7 +98,11 @@ export class AliyunSslClient {
return `${certId}-${this.getCasRegionFromEndpoint(this.opts.endpoint)}`; return `${certId}-${this.getCasRegionFromEndpoint(this.opts.endpoint)}`;
} }
async uploadCert(req: AliyunSslUploadCertReq) : Promise<CasCertId> { async uploadCert(req: AliyunSslUploadCertReq) {
const {certId} = await this.uploadCertificate(req);
return certId;
}
async uploadCertificate(req: AliyunSslUploadCertReq) : Promise<CasCertId> {
const client = await this.getClient(); const client = await this.getClient();
const params = { const params = {
Name: req.name, Name: req.name,
@@ -127,7 +131,7 @@ export class AliyunSslClient {
// 上传证书到阿里云 // 上传证书到阿里云
this.logger.info(`开始上传证书`); this.logger.info(`开始上传证书`);
const certName = CertReader.buildCertName(cert); const certName = CertReader.buildCertName(cert);
const res = await this.uploadCert({ const res = await this.uploadCertificate({
name: certName, name: certName,
cert: cert cert: cert
}); });