perf: 证书支持旧版RSA,pkcs1

This commit is contained in:
xiaojunnuo
2024-09-23 14:32:57 +08:00
parent f9ff9191a1
commit 3d9c3ecb3e
5 changed files with 29 additions and 12 deletions

View File

@@ -244,13 +244,25 @@ export class AcmeService {
if (privateKeyArr.length > 1) {
size = parseInt(privateKeyArr[1]);
}
let encodingType = "pkcs8";
if (privateKeyArr.length > 2) {
encodingType = privateKeyArr[2];
}
if (type == "ec") {
const name: any = "P-" + size;
privateKey = await acme.crypto.createPrivateEcdsaKey(name);
privateKey = await acme.crypto.createPrivateEcdsaKey(name, encodingType);
} else {
privateKey = await acme.crypto.createPrivateRsaKey(size);
privateKey = await acme.crypto.createPrivateRsaKey(size, encodingType);
}
const [key, csr] = await acme.crypto.createCsr(
let createCsr: any = acme.crypto.createCsr;
if (encodingType === "pkcs1") {
//兼容老版本
createCsr = acme.forge.createCsr;
}
const [key, csr] = await createCsr(
{
commonName,
...csrInfo,
@@ -258,6 +270,7 @@ export class AcmeService {
},
privateKey
);
if (dnsProvider == null) {
throw new Error("dnsProvider 不能为空");
}