Replace custom pkcs7 fns with module

This commit is contained in:
Tuan Dang
2024-08-25 20:21:53 -07:00
parent 1317266415
commit f560534493
9 changed files with 73 additions and 118 deletions
@@ -24,26 +24,3 @@ export const revocationReasonToCrlCode = (crlReason: CrlReason) => {
return x509.X509CrlReason.unspecified;
}
};
export const convertCertPemToRaw = (certPem: string) => {
return new x509.X509Certificate(certPem).rawData;
};
export const checkCertValidityAgainstChain = async (cert: x509.X509Certificate, chainCerts: x509.X509Certificate[]) => {
let isSslClientCertValid = true;
let certToVerify = cert;
for await (const issuerCert of chainCerts) {
if (
await certToVerify.verify({
publicKey: issuerCert.publicKey
})
) {
certToVerify = issuerCert; // Move to the next certificate in the chain
} else {
isSslClientCertValid = false;
}
}
return isSslClientCertValid;
};