mirror of
https://github.com/certd/certd.git
synced 2026-04-24 04:17:25 +08:00
perf: 支持http校验方式申请证书
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput, TaskOutput } from '@certd/pipeline';
|
||||
import { CertInfo, CertReader, CertReaderHandleContext } from '@certd/plugin-cert';
|
||||
import * as fs from 'fs';
|
||||
import dayjs from 'dayjs';
|
||||
import { SshAccess, SshClient } from '@certd/plugin-lib';
|
||||
|
||||
@@ -243,27 +242,32 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
|
||||
})
|
||||
hostJksPath!: string;
|
||||
|
||||
@TaskOutput({
|
||||
title: '一体证书保存路径',
|
||||
})
|
||||
hostOnePath!: string;
|
||||
|
||||
async onInstance() {}
|
||||
|
||||
copyFile(srcFile: string, destFile: string) {
|
||||
if (!srcFile || !destFile) {
|
||||
this.logger.warn(`srcFile:${srcFile} 或 destFile:${destFile} 为空,不复制`);
|
||||
return;
|
||||
}
|
||||
const dir = destFile.substring(0, destFile.lastIndexOf('/'));
|
||||
if (!fs.existsSync(dir)) {
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
}
|
||||
fs.copyFileSync(srcFile, destFile);
|
||||
this.logger.info(`复制文件:${srcFile} => ${destFile}`);
|
||||
}
|
||||
// copyFile(srcFile: string, destFile: string) {
|
||||
// if (!srcFile || !destFile) {
|
||||
// this.logger.warn(`srcFile:${srcFile} 或 destFile:${destFile} 为空,不复制`);
|
||||
// return;
|
||||
// }
|
||||
// const dir = destFile.substring(0, destFile.lastIndexOf('/'));
|
||||
// if (!fs.existsSync(dir)) {
|
||||
// fs.mkdirSync(dir, { recursive: true });
|
||||
// }
|
||||
// fs.copyFileSync(srcFile, destFile);
|
||||
// this.logger.info(`复制文件:${srcFile} => ${destFile}`);
|
||||
// }
|
||||
async execute(): Promise<void> {
|
||||
const { cert, accessId } = this;
|
||||
let { crtPath, keyPath, icPath, pfxPath, derPath, jksPath } = this;
|
||||
let { crtPath, keyPath, icPath, pfxPath, derPath, jksPath, onePath } = this;
|
||||
const certReader = new CertReader(cert);
|
||||
|
||||
const handle = async (opts: CertReaderHandleContext) => {
|
||||
const { tmpCrtPath, tmpKeyPath, tmpDerPath, tmpJksPath, tmpPfxPath, tmpIcPath } = opts;
|
||||
const { tmpCrtPath, tmpKeyPath, tmpDerPath, tmpJksPath, tmpPfxPath, tmpIcPath, tmpOnePath } = opts;
|
||||
// if (this.copyToThisHost) {
|
||||
// this.logger.info('复制到目标路径');
|
||||
// this.copyFile(tmpCrtPath, crtPath);
|
||||
@@ -336,6 +340,16 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
|
||||
});
|
||||
this.logger.info(`上传jks证书到主机:${jksPath}`);
|
||||
}
|
||||
|
||||
if (this.onePath) {
|
||||
this.logger.info(`上传一体证书到主机:${this.onePath}`);
|
||||
onePath = this.onePath.trim();
|
||||
transports.push({
|
||||
localPath: tmpOnePath,
|
||||
remotePath: this.onePath,
|
||||
});
|
||||
}
|
||||
|
||||
this.logger.info('开始上传文件到服务器');
|
||||
await sshClient.uploadFiles({
|
||||
connectConf,
|
||||
@@ -350,6 +364,7 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
|
||||
this.hostPfxPath = pfxPath;
|
||||
this.hostDerPath = derPath;
|
||||
this.hostJksPath = jksPath;
|
||||
this.hostOnePath = onePath;
|
||||
};
|
||||
|
||||
await certReader.readCertFile({
|
||||
@@ -376,6 +391,8 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
|
||||
env['HOST_IC_PATH'] = this.hostIcPath || '';
|
||||
env['HOST_PFX_PATH'] = this.hostPfxPath || '';
|
||||
env['HOST_DER_PATH'] = this.hostDerPath || '';
|
||||
env['HOST_JKS_PATH'] = this.hostJksPath || '';
|
||||
env['HOST_ONE_PATH'] = this.hostOnePath || '';
|
||||
}
|
||||
|
||||
const scripts = this.script.split('\n');
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
|
||||
import { createCertDomainGetterInputDefine, createRemoteSelectInputDefine } from '@certd/plugin-lib';
|
||||
import { createCertDomainGetterInputDefine, createRemoteSelectInputDefine, QiniuAccess } from '@certd/plugin-lib';
|
||||
import { CertInfo } from '@certd/plugin-cert';
|
||||
import { optionsUtils } from '@certd/basic/dist/utils/util.options.js';
|
||||
import { QiniuAccess, QiniuClient } from '@certd/plugin-plus';
|
||||
import { QiniuClient } from '@certd/plugin-plus';
|
||||
|
||||
@IsTaskPlugin({
|
||||
name: 'QiniuDeployCertToCDN',
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput, TaskOutput } from '@certd/pipeline';
|
||||
import { QiniuAccess, QiniuClient } from '@certd/plugin-plus';
|
||||
import { QiniuClient } from '@certd/plugin-plus';
|
||||
import { CertInfo } from '@certd/plugin-cert';
|
||||
import { QiniuAccess } from '@certd/plugin-lib';
|
||||
|
||||
@IsTaskPlugin({
|
||||
name: 'QiniuCertUpload',
|
||||
@@ -51,7 +52,7 @@ export class QiniuCertUpload extends AbstractTaskPlugin {
|
||||
async onInstance() {}
|
||||
async execute(): Promise<void> {
|
||||
this.logger.info('开始上传证书到七牛云');
|
||||
const access = (await this.accessService.getById(this.accessId)) as QiniuAccess;
|
||||
const access = await this.accessService.getById<QiniuAccess>(this.accessId);
|
||||
const qiniuClient = new QiniuClient({
|
||||
http: this.ctx.http,
|
||||
access,
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { Autowire } from '@certd/pipeline';
|
||||
|
||||
import { AbstractDnsProvider, CreateRecordOptions, IsDnsProvider, RemoveRecordOptions } from '@certd/plugin-cert';
|
||||
import { TencentAccess } from '@certd/plugin-plus';
|
||||
import { TencentAccess } from '@certd/plugin-lib';
|
||||
|
||||
@IsDnsProvider({
|
||||
name: 'tencent',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { TencentAccess } from '@certd/plugin-plus';
|
||||
import { TencentAccess } from '@certd/plugin-lib';
|
||||
import { CertInfo } from '@certd/plugin-cert';
|
||||
import { ILogger } from '@certd/basic';
|
||||
export class TencentSslClient {
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
import { IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
|
||||
import { AbstractPlusTaskPlugin, TencentAccess } from '@certd/plugin-plus';
|
||||
import { AbstractPlusTaskPlugin } from '@certd/plugin-plus';
|
||||
import { TencentSslClient } from '../../lib/index.js';
|
||||
import dayjs from 'dayjs';
|
||||
import { remove } from 'lodash-es';
|
||||
import { TencentAccess } from '@certd/plugin-lib';
|
||||
|
||||
@IsTaskPlugin({
|
||||
name: 'TencentDeleteExpiringCert',
|
||||
|
||||
+1
-2
@@ -1,9 +1,8 @@
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
|
||||
import { TencentAccess } from '@certd/plugin-plus';
|
||||
import { CertInfo } from '@certd/plugin-cert';
|
||||
import { TencentSslClient } from '../../lib/index.js';
|
||||
import { createRemoteSelectInputDefine } from '@certd/plugin-lib';
|
||||
|
||||
import { TencentAccess } from '@certd/plugin-lib';
|
||||
@IsTaskPlugin({
|
||||
name: 'TencentDeployCertToCDNv2',
|
||||
title: '腾讯云-部署到CDN-v2',
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
|
||||
import { TencentAccess } from '@certd/plugin-plus';
|
||||
import { CertInfo } from '@certd/plugin-cert';
|
||||
|
||||
import { TencentAccess } from '@certd/plugin-lib';
|
||||
@IsTaskPlugin({
|
||||
name: 'DeployCertToTencentCDN',
|
||||
title: '腾讯云-部署到CDN(废弃)',
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
|
||||
import { TencentAccess } from '@certd/plugin-plus';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { TencentAccess } from '@certd/plugin-lib';
|
||||
@IsTaskPlugin({
|
||||
name: 'DeployCertToTencentCLB',
|
||||
title: '腾讯云-部署到CLB',
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
|
||||
import { TencentAccess } from '@certd/plugin-plus';
|
||||
|
||||
import { TencentAccess } from '@certd/plugin-lib';
|
||||
@IsTaskPlugin({
|
||||
name: 'DeployCertToTencentEO',
|
||||
title: '腾讯云-部署到腾讯云EO',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { IsTaskPlugin, pluginGroups, RunStrategy, TaskInput } from '@certd/pipeline';
|
||||
import { AbstractTaskPlugin } from '@certd/pipeline';
|
||||
import { TencentAccess } from '@certd/plugin-plus';
|
||||
import { TencentAccess } from '@certd/plugin-lib';
|
||||
import { createRemoteSelectInputDefine } from '@certd/plugin-lib';
|
||||
|
||||
@IsTaskPlugin({
|
||||
|
||||
Reference in New Issue
Block a user