mirror of
https://github.com/certd/certd.git
synced 2025-11-25 09:10:11 +08:00
chore: 证书支持jks格式
This commit is contained in:
@@ -68,14 +68,14 @@ export class CopyCertToLocalPlugin extends AbstractTaskPlugin {
|
||||
derPath!: string;
|
||||
|
||||
@TaskInput({
|
||||
title: 'p12证书保存路径',
|
||||
helper: '用于java,路径要包含文件名,例如:tmp/cert.p12',
|
||||
title: 'jks证书保存路径',
|
||||
helper: '用于java,路径要包含文件名,例如:tmp/cert.jks',
|
||||
component: {
|
||||
placeholder: 'tmp/cert.p12',
|
||||
placeholder: 'tmp/cert.jks',
|
||||
},
|
||||
rules: [{ type: 'filepath' }],
|
||||
})
|
||||
p12Path!: string;
|
||||
jksPath!: string;
|
||||
|
||||
@TaskInput({
|
||||
title: '域名证书',
|
||||
@@ -119,10 +119,10 @@ export class CopyCertToLocalPlugin extends AbstractTaskPlugin {
|
||||
hostDerPath!: string;
|
||||
|
||||
@TaskOutput({
|
||||
title: 'P12保存路径',
|
||||
type: 'HostP12Path',
|
||||
title: 'jks保存路径',
|
||||
type: 'HostJksPath',
|
||||
})
|
||||
hostP12Path!: string;
|
||||
hostJksPath!: string;
|
||||
|
||||
async onInstance() {}
|
||||
|
||||
@@ -139,10 +139,10 @@ export class CopyCertToLocalPlugin extends AbstractTaskPlugin {
|
||||
throw new Error('只有管理员才能运行此任务');
|
||||
}
|
||||
|
||||
let { crtPath, keyPath, icPath, pfxPath, derPath, p12Path } = this;
|
||||
let { crtPath, keyPath, icPath, pfxPath, derPath, jksPath } = this;
|
||||
const certReader = new CertReader(this.cert);
|
||||
|
||||
const handle = async ({ reader, tmpCrtPath, tmpKeyPath, tmpDerPath, tmpPfxPath, tmpIcPath, tmpP12Path }) => {
|
||||
const handle = async ({ reader, tmpCrtPath, tmpKeyPath, tmpDerPath, tmpPfxPath, tmpIcPath, tmpJksPath }) => {
|
||||
this.logger.info('复制到目标路径');
|
||||
if (crtPath) {
|
||||
crtPath = crtPath.startsWith('/') ? crtPath : path.join(Constants.dataDir, crtPath);
|
||||
@@ -169,10 +169,10 @@ export class CopyCertToLocalPlugin extends AbstractTaskPlugin {
|
||||
this.copyFile(tmpDerPath, derPath);
|
||||
this.hostDerPath = derPath;
|
||||
}
|
||||
if (p12Path) {
|
||||
p12Path = p12Path.startsWith('/') ? p12Path : path.join(Constants.dataDir, p12Path);
|
||||
this.copyFile(tmpP12Path, p12Path);
|
||||
this.hostP12Path = p12Path;
|
||||
if (jksPath) {
|
||||
jksPath = jksPath.startsWith('/') ? jksPath : path.join(Constants.dataDir, jksPath);
|
||||
this.copyFile(tmpJksPath, jksPath);
|
||||
this.hostJksPath = jksPath;
|
||||
}
|
||||
this.logger.info('请注意,如果使用的是相对路径,那么文件就在你的数据库同级目录下,默认是/data/certd/下面');
|
||||
this.logger.info(
|
||||
|
||||
@@ -68,14 +68,14 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
|
||||
derPath!: string;
|
||||
|
||||
@TaskInput({
|
||||
title: 'p12证书保存路径',
|
||||
helper: '需要有写入权限,路径要包含证书文件名,例如:/tmp/cert.p12',
|
||||
title: 'jks证书保存路径',
|
||||
helper: '需要有写入权限,路径要包含证书文件名,例如:/tmp/cert.jks',
|
||||
component: {
|
||||
placeholder: '/root/deploy/nginx/cert.p12',
|
||||
placeholder: '/root/deploy/nginx/cert.jks',
|
||||
},
|
||||
rules: [{ type: 'filepath' }],
|
||||
})
|
||||
p12Path!: string;
|
||||
jksPath!: string;
|
||||
|
||||
@TaskInput({
|
||||
title: '域名证书',
|
||||
@@ -158,9 +158,9 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
|
||||
})
|
||||
hostDerPath!: string;
|
||||
@TaskOutput({
|
||||
title: 'P12保存路径',
|
||||
title: 'jks保存路径',
|
||||
})
|
||||
hostP12Path!: string;
|
||||
hostJksPath!: string;
|
||||
|
||||
async onInstance() {}
|
||||
|
||||
@@ -181,7 +181,7 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
|
||||
const certReader = new CertReader(cert);
|
||||
|
||||
const handle = async (opts: CertReaderHandleContext) => {
|
||||
const { tmpCrtPath, tmpKeyPath, tmpDerPath, tmpP12Path, tmpPfxPath, tmpIcPath } = opts;
|
||||
const { tmpCrtPath, tmpKeyPath, tmpDerPath, tmpJksPath, tmpPfxPath, tmpIcPath } = opts;
|
||||
// if (this.copyToThisHost) {
|
||||
// this.logger.info('复制到目标路径');
|
||||
// this.copyFile(tmpCrtPath, crtPath);
|
||||
@@ -241,12 +241,12 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
|
||||
});
|
||||
this.logger.info(`上传DER证书到主机:${this.derPath}`);
|
||||
}
|
||||
if (this.p12Path) {
|
||||
if (this.jksPath) {
|
||||
transports.push({
|
||||
localPath: tmpP12Path,
|
||||
remotePath: this.p12Path,
|
||||
localPath: tmpJksPath,
|
||||
remotePath: this.jksPath,
|
||||
});
|
||||
this.logger.info(`上传p12证书到主机:${this.p12Path}`);
|
||||
this.logger.info(`上传jks证书到主机:${this.jksPath}`);
|
||||
}
|
||||
this.logger.info('开始上传文件到服务器');
|
||||
await sshClient.uploadFiles({
|
||||
@@ -261,7 +261,7 @@ export class UploadCertToHostPlugin extends AbstractTaskPlugin {
|
||||
this.hostIcPath = this.icPath;
|
||||
this.hostPfxPath = this.pfxPath;
|
||||
this.hostDerPath = this.derPath;
|
||||
this.hostP12Path = this.p12Path;
|
||||
this.hostJksPath = this.jksPath;
|
||||
};
|
||||
|
||||
await certReader.readCertFile({
|
||||
|
||||
Reference in New Issue
Block a user