Skip to content

Commit 78a280b

Browse files
codebyteret57ser
authored andcommitted
fix: failing Node.js certificate spec (electron#31748)
1 parent 3bffb08 commit 78a280b

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

patches/node/.patches

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ fix_readbarrier_undefined_symbol_error_on_woa_arm64.patch
2525
chore_fix_-wimplicit-fallthrough.patch
2626
fix_event_with_invalid_timestamp_in_trace_log.patch
2727
test_fix_test-datetime-change-notify_after_daylight_change.patch
28+
test_add_fixture_trim_option.patch
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Shelley Vohr <shelley.vohr@gmail.com>
3+
Date: Mon, 8 Nov 2021 15:52:17 +0100
4+
Subject: test: add fixture trim option
5+
6+
Fixes a spec failure originating with a strict requirement in BoringSSL
7+
that base64 strings be evenly divisible by 4 in their implementation of
8+
`NETSCAPE_SPKI_b64_decode`.
9+
10+
Fixes that issue by trimming the newlines out of the file.
11+
12+
Upstreamed at https://github.com/nodejs/node/pull/40757.
13+
14+
diff --git a/test/common/fixtures.js b/test/common/fixtures.js
15+
index e5e1d887df525e493989a4aa8df6952a0e5b6c47..2da8aeb6a694e4b45d76bc3908284783d83f6755 100644
16+
--- a/test/common/fixtures.js
17+
+++ b/test/common/fixtures.js
18+
@@ -15,8 +15,13 @@ function readFixtureSync(args, enc) {
19+
return fs.readFileSync(fixturesPath(args), enc);
20+
}
21+
22+
-function readFixtureKey(name, enc) {
23+
- return fs.readFileSync(fixturesPath('keys', name), enc);
24+
+function readFixtureKey(name, enc, trim) {
25+
+ let result = fs.readFileSync(fixturesPath('keys', name), enc);
26+
+ if (trim) {
27+
+ result = Buffer.from(result.toString().trim(), 'utf8');
28+
+ }
29+
+
30+
+ return result;
31+
}
32+
33+
function readFixtureKeys(enc, ...names) {
34+
diff --git a/test/parallel/test-crypto-certificate.js b/test/parallel/test-crypto-certificate.js
35+
index 4a5f1f149fe6c739f7f1d2ee17df6e61a942d621..a21fbff81c840da29034cb07ae2bd711cfe78b0a 100644
36+
--- a/test/parallel/test-crypto-certificate.js
37+
+++ b/test/parallel/test-crypto-certificate.js
38+
@@ -30,9 +30,9 @@ const { Certificate } = crypto;
39+
const fixtures = require('../common/fixtures');
40+
41+
// Test Certificates
42+
-const spkacValid = fixtures.readKey('rsa_spkac.spkac');
43+
+const spkacValid = fixtures.readKey('rsa_spkac.spkac', null, true);
44+
const spkacChallenge = 'this-is-a-challenge';
45+
-const spkacFail = fixtures.readKey('rsa_spkac_invalid.spkac');
46+
+const spkacFail = fixtures.readKey('rsa_spkac_invalid.spkac', null, true);
47+
const spkacPublicPem = fixtures.readKey('rsa_public.pem');
48+
49+
function copyArrayBuffer(buf) {

script/node-disabled-tests.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"parallel/test-code-cache",
1515
"parallel/test-crypto-aes-wrap",
1616
"parallel/test-crypto-authenticated-stream",
17-
"parallel/test-crypto-certificate",
1817
"parallel/test-crypto-des3-wrap",
1918
"parallel/test-crypto-dh-stateless",
2019
"parallel/test-crypto-ecb",

0 commit comments

Comments
 (0)