mirror of https://github.com/certd/certd
fix: 修复配置了cdn cname后申请失败的bug
parent
1b7debc6a4
commit
4a5fa767ed
|
@ -171,7 +171,6 @@ module.exports = async (client, userOpts) => {
|
||||||
await challengeFunc(authz);
|
await challengeFunc(authz);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function runAllPromise(tasks) {
|
function runAllPromise(tasks) {
|
||||||
let promise = Promise.resolve();
|
let promise = Promise.resolve();
|
||||||
tasks.forEach((task) => {
|
tasks.forEach((task) => {
|
||||||
|
@ -210,11 +209,18 @@ module.exports = async (client, userOpts) => {
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
log('证书申请失败');
|
log('证书申请失败');
|
||||||
throw e;
|
log(e);
|
||||||
|
throw new Error(`证书申请失败:${e.message}`);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
log(`清理challenge痕迹,length:${clearTasks.length}`);
|
log(`清理challenge痕迹,length:${clearTasks.length}`);
|
||||||
await runAllPromise(clearTasks);
|
try {
|
||||||
|
await runAllPromise(clearTasks);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
log('清理challenge失败');
|
||||||
|
log(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// try {
|
// try {
|
||||||
|
|
|
@ -178,6 +178,7 @@ export class AcmeService {
|
||||||
csr,
|
csr,
|
||||||
email: email,
|
email: email,
|
||||||
termsOfServiceAgreed: true,
|
termsOfServiceAgreed: true,
|
||||||
|
skipChallengeVerification: true,
|
||||||
challengePriority: ["dns-01"],
|
challengePriority: ["dns-01"],
|
||||||
challengeCreateFn: async (authz: acme.Authorization, challenge: Challenge, keyAuthorization: string): Promise<any> => {
|
challengeCreateFn: async (authz: acme.Authorization, challenge: Challenge, keyAuthorization: string): Promise<any> => {
|
||||||
return await this.challengeCreateFn(authz, challenge, keyAuthorization, dnsProvider);
|
return await this.challengeCreateFn(authz, challenge, keyAuthorization, dnsProvider);
|
||||||
|
|
|
@ -1,12 +1,17 @@
|
||||||
import { Autowire, HttpClient, ILogger } from "@certd/pipeline";
|
import { Autowire, HttpClient, ILogger } from '@certd/pipeline';
|
||||||
import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from "@certd/plugin-cert";
|
import {
|
||||||
import _ from "lodash";
|
AbstractDnsProvider,
|
||||||
import { DnspodAccess } from "../access";
|
CreateRecordOptions,
|
||||||
|
IsDnsProvider,
|
||||||
|
RemoveRecordOptions,
|
||||||
|
} from '@certd/plugin-cert';
|
||||||
|
import _ from 'lodash';
|
||||||
|
import { DnspodAccess } from '../access';
|
||||||
|
|
||||||
@IsDnsProvider({
|
@IsDnsProvider({
|
||||||
name: 'dnspod',
|
name: 'dnspod',
|
||||||
title: 'dnspod(腾讯云)',
|
title: 'dnspod(已过时)',
|
||||||
desc: '腾讯云的域名解析接口已迁移到dnspod',
|
desc: '请尽快换成腾讯云类型',
|
||||||
accessType: 'dnspod',
|
accessType: 'dnspod',
|
||||||
})
|
})
|
||||||
export class DnspodDnsProvider extends AbstractDnsProvider {
|
export class DnspodDnsProvider extends AbstractDnsProvider {
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
import {Autowire, HttpClient, ILogger} from "@certd/pipeline";
|
import { Autowire, HttpClient, ILogger } from '@certd/pipeline';
|
||||||
import {AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions} from "@certd/plugin-cert";
|
import {
|
||||||
import {TencentAccess} from "../access";
|
AbstractDnsProvider,
|
||||||
|
CreateRecordOptions,
|
||||||
|
IsDnsProvider,
|
||||||
|
RemoveRecordOptions,
|
||||||
|
} from '@certd/plugin-cert';
|
||||||
|
import { TencentAccess } from '../access';
|
||||||
import tencentcloud from 'tencentcloud-sdk-nodejs/index';
|
import tencentcloud from 'tencentcloud-sdk-nodejs/index';
|
||||||
|
import TencentCloudSDKHttpException from 'tencentcloud-sdk-nodejs/tencentcloud/common/exception/tencent_cloud_sdk_exception';
|
||||||
|
|
||||||
const DnspodClient = tencentcloud.dnspod.v20210323.Client;
|
const DnspodClient = tencentcloud.dnspod.v20210323.Client;
|
||||||
@IsDnsProvider({
|
@IsDnsProvider({
|
||||||
|
@ -24,10 +30,9 @@ export class TencentDnsProvider extends AbstractDnsProvider {
|
||||||
endpoint = 'dnspod.tencentcloudapi.com';
|
endpoint = 'dnspod.tencentcloudapi.com';
|
||||||
|
|
||||||
async onInstance() {
|
async onInstance() {
|
||||||
|
|
||||||
const clientConfig = {
|
const clientConfig = {
|
||||||
credential: this.access,
|
credential: this.access,
|
||||||
region: "",
|
region: '',
|
||||||
profile: {
|
profile: {
|
||||||
httpProfile: {
|
httpProfile: {
|
||||||
endpoint: this.endpoint,
|
endpoint: this.endpoint,
|
||||||
|
@ -35,50 +40,59 @@ export class TencentDnsProvider extends AbstractDnsProvider {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// 实例化要请求产品的client对象,clientProfile是可选的
|
// 实例化要请求产品的client对象,clientProfile是可选的
|
||||||
this.client = new DnspodClient(clientConfig);
|
this.client = new DnspodClient(clientConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
async createRecord(options: CreateRecordOptions): Promise<any> {
|
async createRecord(options: CreateRecordOptions): Promise<any> {
|
||||||
const { fullRecord, value, type,domain } = options;
|
const { fullRecord, value, type, domain } = options;
|
||||||
this.logger.info('添加域名解析:', fullRecord, value);
|
this.logger.info('添加域名解析:', fullRecord, value);
|
||||||
const rr = fullRecord.replace('.' + domain, '');
|
const rr = fullRecord.replace('.' + domain, '');
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
"Domain": domain,
|
Domain: domain,
|
||||||
"RecordType": type,
|
RecordType: type,
|
||||||
"RecordLine": "默认",
|
RecordLine: '默认',
|
||||||
"Value": value,
|
Value: value,
|
||||||
"SubDomain": rr
|
SubDomain: rr,
|
||||||
};
|
};
|
||||||
|
|
||||||
const ret = await this.client.CreateRecord(params)
|
try {
|
||||||
/*
|
const ret = await this.client.CreateRecord(params);
|
||||||
{
|
this.logger.info(
|
||||||
"RecordId": 162,
|
'添加域名解析成功:',
|
||||||
"RequestId": "ab4f1426-ea15-42ea-8183-dc1b44151166"
|
fullRecord,
|
||||||
}
|
value,
|
||||||
*/
|
JSON.stringify(ret)
|
||||||
this.logger.info(
|
);
|
||||||
'添加域名解析成功:',
|
/*
|
||||||
fullRecord,
|
{
|
||||||
value,
|
"RecordId": 162,
|
||||||
JSON.stringify(ret)
|
"RequestId": "ab4f1426-ea15-42ea-8183-dc1b44151166"
|
||||||
);
|
}
|
||||||
return ret;
|
*/
|
||||||
|
return ret;
|
||||||
|
} catch (e: any) {
|
||||||
|
if (e instanceof TencentCloudSDKHttpException) {
|
||||||
|
if (e.code === 'InvalidParameter.DomainRecordExist') {
|
||||||
|
this.logger.info('域名解析已存在,无需重复添加:', fullRecord, value);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async removeRecord(options: RemoveRecordOptions<any>) {
|
async removeRecord(options: RemoveRecordOptions<any>) {
|
||||||
const { fullRecord, value, domain,record } = options;
|
const { fullRecord, value, domain, record } = options;
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
"Domain": domain,
|
Domain: domain,
|
||||||
"RecordId": record.RecordId
|
RecordId: record.RecordId,
|
||||||
};
|
};
|
||||||
const ret = await this.client.DeleteRecord(params)
|
const ret = await this.client.DeleteRecord(params);
|
||||||
this.logger.info('删除域名解析成功:', fullRecord, value);
|
this.logger.info('删除域名解析成功:', fullRecord, value);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
new TencentDnsProvider();
|
new TencentDnsProvider();
|
||||||
|
|
Loading…
Reference in New Issue