From 53c38cf714a6f7486abbf1d71c9f48f56a790100 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Tue, 17 Dec 2024 22:50:18 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=94=AF=E6=8C=81=E4=B8=80=E4=BD=93?= =?UTF-8?q?=E8=AF=81=E4=B9=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/plugin/cert-plugin/cert-reader.ts | 8 ++++++-- .../plugin/upload-to-host/index.ts | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/packages/plugins/plugin-cert/src/plugin/cert-plugin/cert-reader.ts b/packages/plugins/plugin-cert/src/plugin/cert-plugin/cert-reader.ts index 1b53a909..4128830d 100644 --- a/packages/plugins/plugin-cert/src/plugin/cert-plugin/cert-reader.ts +++ b/packages/plugins/plugin-cert/src/plugin/cert-plugin/cert-reader.ts @@ -15,6 +15,7 @@ export type CertReaderHandleContext = { tmpDerPath?: string; tmpIcPath?: string; tmpJksPath?: string; + tmpOnePath?: string; }; export type CertReaderHandle = (ctx: CertReaderHandleContext) => Promise; export type HandleOpts = { logger: ILogger; handle: CertReaderHandle }; @@ -95,7 +96,7 @@ export class CertReader { return domains; } - saveToFile(type: "crt" | "key" | "pfx" | "der" | "oc" | "ic" | "jks", filepath?: string) { + saveToFile(type: "crt" | "key" | "pfx" | "der" | "oc" | "one" | "ic" | "jks", filepath?: string) { if (!this.cert[type]) { return; } @@ -109,7 +110,7 @@ export class CertReader { if (!fs.existsSync(dir)) { fs.mkdirSync(dir, { recursive: true }); } - if (type === "crt" || type === "key" || type === "ic" || type === "oc") { + if (type === "crt" || type === "key" || type === "ic" || type === "oc" || type === "one") { fs.writeFileSync(filepath, this.cert[type]); } else { fs.writeFileSync(filepath, Buffer.from(this.cert[type], "base64")); @@ -127,6 +128,7 @@ export class CertReader { const tmpOcPath = this.saveToFile("oc"); const tmpDerPath = this.saveToFile("der"); const tmpJksPath = this.saveToFile("jks"); + const tmpOnePath = this.saveToFile("one"); logger.info("本地文件写入成功"); try { return await opts.handle({ @@ -138,6 +140,7 @@ export class CertReader { tmpIcPath: tmpIcPath, tmpJksPath: tmpJksPath, tmpOcPath: tmpOcPath, + tmpOnePath, }); } catch (err) { throw err; @@ -156,6 +159,7 @@ export class CertReader { removeFile(tmpDerPath); removeFile(tmpIcPath); removeFile(tmpJksPath); + removeFile(tmpOnePath); } } diff --git a/packages/ui/certd-server/src/plugins/plugin-host/plugin/upload-to-host/index.ts b/packages/ui/certd-server/src/plugins/plugin-host/plugin/upload-to-host/index.ts index 933ead20..20402983 100644 --- a/packages/ui/certd-server/src/plugins/plugin-host/plugin/upload-to-host/index.ts +++ b/packages/ui/certd-server/src/plugins/plugin-host/plugin/upload-to-host/index.ts @@ -38,6 +38,7 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin { { value: 'pfx', label: 'pfx,一般用于IIS' }, { value: 'der', label: 'der,一般用于Apache' }, { value: 'jks', label: 'jks,一般用于JAVA应用' }, + { value: 'one', label: '证书私钥一体,crt+key简单合并为一个pem文件' }, ], }, required: true, @@ -150,6 +151,24 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin { }) jksPath!: string; + @TaskInput({ + title: '一体证书保存路径', + helper: '填写应用原本的证书保存路径,路径要包含证书文件名,例如:/tmp/crt_key.pem', + component: { + placeholder: '/root/deploy/app/crt_key.pem', + }, + mergeScript: ` + return { + show: ctx.compute(({form})=>{ + return form.certType === 'one'; + }) + } + `, + required: true, + rules: [{ type: 'filepath' }], + }) + onePath!: string; + @TaskInput({ title: '主机登录配置', helper: 'access授权',