Skip to content

Commit

Permalink
tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakprabhakara committed Nov 9, 2023
1 parent 78f4ea3 commit 058375b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/validateSignature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 =
Expand Down

0 comments on commit 058375b

Please sign in to comment.