From 058375baaa1d32855e6649a61171ff09e5d05d33 Mon Sep 17 00:00:00 2001 From: Deepak Prabhakara Date: Thu, 9 Nov 2023 23:36:24 +0100 Subject: [PATCH] tweak --- lib/validateSignature.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/validateSignature.ts b/lib/validateSignature.ts index c97f8850..b97fa584 100644 --- a/lib/validateSignature.ts +++ b/lib/validateSignature.ts @@ -3,12 +3,7 @@ import { select } from 'xpath'; import { thumbprint } from './utils'; import { parseFromString } from './utils'; -const certToPEM = (cert) => { - if (cert.indexOf(',') !== -1) { - const _certs = cert.split(','); - return _certs.map((_cert) => certToPEM(_cert)).join(','); - } - +const _certToPEM = (cert) => { if (cert.indexOf('BEGIN CERTIFICATE') === -1 && cert.indexOf('END CERTIFICATE') === -1) { cert = cert.match(/.{1,64}/g).join('\n'); cert = '-----BEGIN CERTIFICATE-----\n' + cert; @@ -19,6 +14,15 @@ const certToPEM = (cert) => { } }; +const certToPEM = (cert) => { + if (cert.indexOf(',') !== -1) { + const _certs = cert.split(','); + return _certs.map((_cert) => _certToPEM(_cert)).join(','); + } + + return _certToPEM(cert); +}; + const hasValidSignature = (xml, cert, certThumbprint) => { const doc = parseFromString(xml); let signature =