mirror of https://github.com/certd/certd
perf: 支持一体证书
parent
0e7578043e
commit
53c38cf714
|
@ -15,6 +15,7 @@ export type CertReaderHandleContext = {
|
||||||
tmpDerPath?: string;
|
tmpDerPath?: string;
|
||||||
tmpIcPath?: string;
|
tmpIcPath?: string;
|
||||||
tmpJksPath?: string;
|
tmpJksPath?: string;
|
||||||
|
tmpOnePath?: string;
|
||||||
};
|
};
|
||||||
export type CertReaderHandle = (ctx: CertReaderHandleContext) => Promise<void>;
|
export type CertReaderHandle = (ctx: CertReaderHandleContext) => Promise<void>;
|
||||||
export type HandleOpts = { logger: ILogger; handle: CertReaderHandle };
|
export type HandleOpts = { logger: ILogger; handle: CertReaderHandle };
|
||||||
|
@ -95,7 +96,7 @@ export class CertReader {
|
||||||
return domains;
|
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]) {
|
if (!this.cert[type]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -109,7 +110,7 @@ export class CertReader {
|
||||||
if (!fs.existsSync(dir)) {
|
if (!fs.existsSync(dir)) {
|
||||||
fs.mkdirSync(dir, { recursive: true });
|
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]);
|
fs.writeFileSync(filepath, this.cert[type]);
|
||||||
} else {
|
} else {
|
||||||
fs.writeFileSync(filepath, Buffer.from(this.cert[type], "base64"));
|
fs.writeFileSync(filepath, Buffer.from(this.cert[type], "base64"));
|
||||||
|
@ -127,6 +128,7 @@ export class CertReader {
|
||||||
const tmpOcPath = this.saveToFile("oc");
|
const tmpOcPath = this.saveToFile("oc");
|
||||||
const tmpDerPath = this.saveToFile("der");
|
const tmpDerPath = this.saveToFile("der");
|
||||||
const tmpJksPath = this.saveToFile("jks");
|
const tmpJksPath = this.saveToFile("jks");
|
||||||
|
const tmpOnePath = this.saveToFile("one");
|
||||||
logger.info("本地文件写入成功");
|
logger.info("本地文件写入成功");
|
||||||
try {
|
try {
|
||||||
return await opts.handle({
|
return await opts.handle({
|
||||||
|
@ -138,6 +140,7 @@ export class CertReader {
|
||||||
tmpIcPath: tmpIcPath,
|
tmpIcPath: tmpIcPath,
|
||||||
tmpJksPath: tmpJksPath,
|
tmpJksPath: tmpJksPath,
|
||||||
tmpOcPath: tmpOcPath,
|
tmpOcPath: tmpOcPath,
|
||||||
|
tmpOnePath,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw err;
|
throw err;
|
||||||
|
@ -156,6 +159,7 @@ export class CertReader {
|
||||||
removeFile(tmpDerPath);
|
removeFile(tmpDerPath);
|
||||||
removeFile(tmpIcPath);
|
removeFile(tmpIcPath);
|
||||||
removeFile(tmpJksPath);
|
removeFile(tmpJksPath);
|
||||||
|
removeFile(tmpOnePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
|
||||||
{ value: 'pfx', label: 'pfx,一般用于IIS' },
|
{ value: 'pfx', label: 'pfx,一般用于IIS' },
|
||||||
{ value: 'der', label: 'der,一般用于Apache' },
|
{ value: 'der', label: 'der,一般用于Apache' },
|
||||||
{ value: 'jks', label: 'jks,一般用于JAVA应用' },
|
{ value: 'jks', label: 'jks,一般用于JAVA应用' },
|
||||||
|
{ value: 'one', label: '证书私钥一体,crt+key简单合并为一个pem文件' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -150,6 +151,24 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
|
||||||
})
|
})
|
||||||
jksPath!: string;
|
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({
|
@TaskInput({
|
||||||
title: '主机登录配置',
|
title: '主机登录配置',
|
||||||
helper: 'access授权',
|
helper: 'access授权',
|
||||||
|
|
Loading…
Reference in New Issue