From 29362ce67360513bf20736fc65e7916369efe74c Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Fri, 22 Nov 2024 10:33:06 +0100 Subject: [PATCH] test: make x509 crypto tests work with BoringSSL PR-URL: https://github.com/nodejs/node/pull/55927 Reviewed-By: Richard Lau Reviewed-By: LiviaMedeiros Reviewed-By: Luigi Pinca --- test/parallel/test-crypto-x509.js | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/test/parallel/test-crypto-x509.js b/test/parallel/test-crypto-x509.js index 15e1f53bb05faf..bd906c25b9ee19 100644 --- a/test/parallel/test-crypto-x509.js +++ b/test/parallel/test-crypto-x509.js @@ -113,7 +113,7 @@ const der = Buffer.from( '5A:42:63:E0:21:2F:D6:70:63:07:96:6F:27:A7:78:12:08:02:7A:8B' ); assert.strictEqual(x509.keyUsage, undefined); - assert.strictEqual(x509.serialNumber, '147D36C1C2F74206DE9FAB5F2226D78ADB00A426'); + assert.strictEqual(x509.serialNumber.toUpperCase(), '147D36C1C2F74206DE9FAB5F2226D78ADB00A426'); assert.deepStrictEqual(x509.raw, der); @@ -255,6 +255,16 @@ oans248kpal88CGqsN2so/wZKxVnpiXlPHMdiNL7hRSUqlHkUi07FrP2Htg8kjI= }); mc.port2.postMessage(x509); + const modulusOSSL = 'D456320AFB20D3827093DC2C4284ED04DFBABD56E1DDAE529E28B790CD42' + + '56DB273349F3735FFD337C7A6363ECCA5A27B7F73DC7089A96C6D886DB0C' + + '62388F1CDD6A963AFCD599D5800E587A11F908960F84ED50BA25A28303EC' + + 'DA6E684FBE7BAEDC9CE8801327B1697AF25097CEE3F175E400984C0DB6A8' + + 'EB87BE03B4CF94774BA56FFFC8C63C68D6ADEB60ABBE69A7B14AB6A6B9E7' + + 'BAA89B5ADAB8EB07897C07F6D4FA3D660DFF574107D28E8F63467A788624' + + 'C574197693E959CEA1362FFAE1BBA10C8C0D88840ABFEF103631B2E8F5C3' + + '9B5548A7EA57E8A39F89291813F45A76C448033A2B7ED8403F4BAA147CF3' + + '5E2D2554AA65CE49695797095BF4DC6B'; + // Verify that legacy encoding works const legacyObjectCheck = { subject: Object.assign({ __proto__: null }, { @@ -279,15 +289,7 @@ oans248kpal88CGqsN2so/wZKxVnpiXlPHMdiNL7hRSUqlHkUi07FrP2Htg8kjI= 'OCSP - URI': ['http://ocsp.nodejs.org/'], 'CA Issuers - URI': ['http://ca.nodejs.org/ca.cert'] }), - modulus: 'D456320AFB20D3827093DC2C4284ED04DFBABD56E1DDAE529E28B790CD42' + - '56DB273349F3735FFD337C7A6363ECCA5A27B7F73DC7089A96C6D886DB0C' + - '62388F1CDD6A963AFCD599D5800E587A11F908960F84ED50BA25A28303EC' + - 'DA6E684FBE7BAEDC9CE8801327B1697AF25097CEE3F175E400984C0DB6A8' + - 'EB87BE03B4CF94774BA56FFFC8C63C68D6ADEB60ABBE69A7B14AB6A6B9E7' + - 'BAA89B5ADAB8EB07897C07F6D4FA3D660DFF574107D28E8F63467A788624' + - 'C574197693E959CEA1362FFAE1BBA10C8C0D88840ABFEF103631B2E8F5C3' + - '9B5548A7EA57E8A39F89291813F45A76C448033A2B7ED8403F4BAA147CF3' + - '5E2D2554AA65CE49695797095BF4DC6B', + modulusPattern: new RegExp(`^${modulusOSSL}$`, 'i'), bits: 2048, exponent: '0x10001', valid_from: 'Sep 3 21:40:37 2022 GMT', @@ -300,7 +302,7 @@ oans248kpal88CGqsN2so/wZKxVnpiXlPHMdiNL7hRSUqlHkUi07FrP2Htg8kjI= '51:62:18:39:E2:E2:77:F5:86:11:E8:C0:CA:54:43:7C:76:83:19:05:D0:03:' + '24:21:B8:EB:14:61:FB:24:16:EB:BD:51:1A:17:91:04:30:03:EB:68:5F:DC:' + '86:E1:D1:7C:FB:AF:78:ED:63:5F:29:9C:32:AF:A1:8E:22:96:D1:02', - serialNumber: '147D36C1C2F74206DE9FAB5F2226D78ADB00A426' + serialNumberPattern: /^147D36C1C2F74206DE9FAB5F2226D78ADB00A426$/i }; const legacyObject = x509.toLegacyObject(); @@ -309,7 +311,7 @@ oans248kpal88CGqsN2so/wZKxVnpiXlPHMdiNL7hRSUqlHkUi07FrP2Htg8kjI= assert.deepStrictEqual(legacyObject.subject, legacyObjectCheck.subject); assert.deepStrictEqual(legacyObject.issuer, legacyObjectCheck.issuer); assert.deepStrictEqual(legacyObject.infoAccess, legacyObjectCheck.infoAccess); - assert.strictEqual(legacyObject.modulus, legacyObjectCheck.modulus); + assert.match(legacyObject.modulus, legacyObjectCheck.modulusPattern); assert.strictEqual(legacyObject.bits, legacyObjectCheck.bits); assert.strictEqual(legacyObject.exponent, legacyObjectCheck.exponent); assert.strictEqual(legacyObject.valid_from, legacyObjectCheck.valid_from); @@ -318,9 +320,9 @@ oans248kpal88CGqsN2so/wZKxVnpiXlPHMdiNL7hRSUqlHkUi07FrP2Htg8kjI= assert.strictEqual( legacyObject.fingerprint256, legacyObjectCheck.fingerprint256); - assert.strictEqual( + assert.match( legacyObject.serialNumber, - legacyObjectCheck.serialNumber); + legacyObjectCheck.serialNumberPattern); } {