perf: 支持jks

pull/243/head
xiaojunnuo 2024-11-13 11:34:34 +08:00
parent d2ce72e4aa
commit 889eaaea92
2 changed files with 5 additions and 5 deletions

View File

@ -152,28 +152,28 @@ export abstract class CertApplyBasePlugin extends AbstractTaskPlugin {
} }
this._result.pipelinePrivateVars.cert = cert; this._result.pipelinePrivateVars.cert = cert;
if (cert.pfx == null || cert.der == null) { if (cert.pfx == null || cert.der == null || cert.jks == null) {
try { try {
const converter = new CertConverter({ logger: this.logger }); const converter = new CertConverter({ logger: this.logger });
const res = await converter.convert({ const res = await converter.convert({
cert, cert,
pfxPassword: this.pfxPassword, pfxPassword: this.pfxPassword,
}); });
if (res.pfxPath) { if (cert.pfx == null && res.pfxPath) {
const pfxBuffer = fs.readFileSync(res.pfxPath); const pfxBuffer = fs.readFileSync(res.pfxPath);
cert.pfx = pfxBuffer.toString("base64"); cert.pfx = pfxBuffer.toString("base64");
fs.unlinkSync(res.pfxPath); fs.unlinkSync(res.pfxPath);
isNew = true; isNew = true;
} }
if (res.derPath) { if (cert.der == null && res.derPath) {
const derBuffer = fs.readFileSync(res.derPath); const derBuffer = fs.readFileSync(res.derPath);
cert.der = derBuffer.toString("base64"); cert.der = derBuffer.toString("base64");
fs.unlinkSync(res.derPath); fs.unlinkSync(res.derPath);
isNew = true; isNew = true;
} }
if (res.jksPath) { if (cert.jks == null && res.jksPath) {
const jksBuffer = fs.readFileSync(res.jksPath); const jksBuffer = fs.readFileSync(res.jksPath);
cert.jks = jksBuffer.toString("base64"); cert.jks = jksBuffer.toString("base64");
fs.unlinkSync(res.jksPath); fs.unlinkSync(res.jksPath);

View File

@ -30,7 +30,7 @@ export class CertConverter {
// 转der // 转der
derPath = await this.convertDer(ctx); derPath = await this.convertDer(ctx);
//jksPath = await this.convertJks(ctx, opts.pfxPassword); jksPath = await this.convertJks(ctx, opts.pfxPassword);
}; };
await certReader.readCertFile({ logger: this.logger, handle }); await certReader.readCertFile({ logger: this.logger, handle });