diff --git a/lib/certUtils.js b/lib/certUtils.js index a8b602fd..555a585f 100644 --- a/lib/certUtils.js +++ b/lib/certUtils.js @@ -125,8 +125,10 @@ class Certificate { let kv; let v = ext.parsedValue || ext.extnValue; - if (v.valueBlock) v = decodeValue(v.valueBlock); try { + if (v.valueBlock) { + v = decodeValue(v.valueBlock); + } kv = resolveOid(ext.extnID, v); } catch (err) { if (ext.critical === false) { @@ -284,6 +286,8 @@ function decodeValue(valueBlock) { // console.log("blockType", blockType); // console.log("valueBlock", valueBlock); switch (blockType) { + case "LocalIntegerValueBlock": + return valueBlock.valueDec; case "LocalOctetStringValueBlock": return valueBlock.valueHex; case "LocalUtf8StringValueBlock": @@ -576,4 +580,4 @@ const helpers = { resolveOid, }; -export { Certificate, CertManager, CRL, helpers }; \ No newline at end of file +export { Certificate, CertManager, CRL, helpers }; diff --git a/package.json b/package.json index e03f21a2..87171dff 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fido2-lib", - "version": "3.4.4", + "version": "3.5.0", "description": "A library for performing FIDO 2.0 / WebAuthn functionality", "type": "module", "main": "dist/main.cjs", diff --git a/test/certUtils.test.js b/test/certUtils.test.js index dae0fdc9..f844043f 100644 --- a/test/certUtils.test.js +++ b/test/certUtils.test.js @@ -189,6 +189,11 @@ describe("cert utils", function() { assert.isTrue(u2fTransports.has("usb")); }); + it("does not throw for non-critical extensions, when unknown extension types are included", function() { + const cert = new Certificate(h.certs.certificateWithIntegerExtension); + const extensions = cert.getExtensions(); + }); + it("returns correct extensions for root", function() { const cert = new Certificate(h.certs.yubicoRoot); const extensions = cert.getExtensions(); diff --git a/test/helpers/fido2-helpers.js b/test/helpers/fido2-helpers.js index 0e4b358e..6da696ab 100644 --- a/test/helpers/fido2-helpers.js +++ b/test/helpers/fido2-helpers.js @@ -3784,12 +3784,15 @@ const tpmAttestation = new Uint8Array([ const truUCert = "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNTekNDQWZLZ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Attestation, yubicoRoot, feitianFido2, tpmAttestation, truUCert, + certificateWithIntegerExtension, }; /** ******************************************************************************