fix: PEM bundle parsing
This commit is contained in:
+1
-1
@@ -41,7 +41,7 @@ export function pfxToPem(pfxBuffer: Buffer, password = ''): PemBundle {
|
||||
}
|
||||
|
||||
export function parsePemBundle(bundle: string): PemBundle {
|
||||
const blocks = bundle.match(/-----BEGIN [^-]+-----[\s\S]+?-----END [^-]+-----/g) ?? [];
|
||||
const blocks = bundle.replace(/\\n/g, '\n').match(/-----BEGIN [^-]+-----[\s\S]+?-----END [^-]+-----/g) ?? [];
|
||||
const privateKeyPem = blocks.find(b => b.includes('PRIVATE KEY')) ?? '';
|
||||
const certs = blocks.filter(b => b.includes('CERTIFICATE'));
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user