pull/189/head
xiaojunnuo 2024-09-06 22:32:29 +08:00
parent b80210f24b
commit 1133d6b0f7
3 changed files with 26 additions and 26 deletions

11
.gitignore vendored
View File

@ -19,21 +19,10 @@ gen
/*.log
/packages/ui/*/.idea
/packages/ui/*/node_modules
/packages/*/node_modules
/packages/ui/certd-server/tmp/
/packages/ui/certd-ui/dist/
/other
/dev-sidecar-test
/packages/core/certd/yarn.lock
/packages/test
/test/own
/pnpm-lock.yaml
docker/image/workspace
/packages/core/lego
tsconfig.tsbuildinfo
test/**/*.js

View File

@ -239,7 +239,10 @@ export class AcmeService {
const privateKeyType = options.privateKeyType || "rsa_2048";
const privateKeyArr = privateKeyType.split("_");
const type = privateKeyArr[0];
const size = parseInt(privateKeyArr[1]);
let size = 2048;
if (privateKeyArr.length > 1) {
size = parseInt(privateKeyArr[1]);
}
if (type == "ec") {
const name: any = "P-" + size;
privateKey = await acme.crypto.createPrivateEcdsaKey(name);

View File

@ -144,6 +144,7 @@ export abstract class CertApplyBasePlugin extends AbstractTaskPlugin {
this._result.pipelineVars.certExpiresTime = dayjs(certReader.detail.notAfter).valueOf();
if (cert.pfx == null || cert.der == null) {
try {
const converter = new CertConverter({ logger: this.logger });
const res = await converter.convert({
cert,
@ -157,6 +158,9 @@ export abstract class CertApplyBasePlugin extends AbstractTaskPlugin {
this.logger.info("转换证书格式成功");
isNew = true;
} catch (e) {
this.logger.error("转换证书格式失败", e);
}
}
if (isNew) {
@ -171,8 +175,12 @@ export abstract class CertApplyBasePlugin extends AbstractTaskPlugin {
const zip = new JSZip();
zip.file("cert.crt", cert.crt);
zip.file("cert.key", cert.key);
if (cert.pfx) {
zip.file("cert.pfx", Buffer.from(cert.pfx, "base64"));
}
if (cert.der) {
zip.file("cert.der", Buffer.from(cert.der, "base64"));
}
const content = await zip.generateAsync({ type: "nodebuffer" });
this.saveFile(filename, content);
this.logger.info(`已保存文件:${filename}`);