Skip to content

Commit

Permalink
feat: Allow non trusted certs
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Dec 2, 2024
1 parent 8416546 commit b1c6ff7
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions packages/x509-utils/src/x509/x509-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ const validateX509CertificateChainImpl = async ({
// x5c always starts with the leaf cert at index 0 and then the cas. Our internal pkijs service expects it the other way around. Before calling this function the change has been revered
const chain = await Promise.all(pemOrDerChain.map((raw) => parseCertificate(raw)))
const x5cOrdereredChain = reversed ? [...chain] : [...chain].reverse()
console.log(`x5c orderered chain (reverse: ${reversed}): ${x5cOrdereredChain.map((cert) => cert.certificateInfo.subject.dn.DN).join(', ')}`)

const trustedCerts = trustedPEMs ? await Promise.all(trustedPEMs.map((raw) => parseCertificate(raw))) : undefined
const blindlyTrusted =
Expand Down Expand Up @@ -227,7 +226,7 @@ const validateX509CertificateChainImpl = async ({
)
if (!result) {
// First cert needs to be self signed
if (i == 0) {
if (i == 0 && !reversed && !disallowReversedChain) {
return await validateX509CertificateChainImpl({
reversed: true,
chain: [...pemOrDerChain].reverse(),
Expand Down

0 comments on commit b1c6ff7

Please sign in to comment.