Skip to content

Commit 602b9d6

Browse files
richardlautargos
authored andcommitted
test: update tests for OpenSSL 3.0.14
Starting from OpenSSL 3.0.14, 3.1.6, 3.2.2, and 3.3.1, OpenSSL was fixed to return an error reason string for bad/unknown application protocols. Update tests to handle both the old `ECONNRESET` error on older versions of OpenSSL and the new `ERR_SSL_TLSV1_ALERT_NO_APPLICATION_PROTOCOL` on newer versions of OpenSSL. Refs: openssl/openssl#24338 PR-URL: #53373 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
1 parent 45b59e5 commit 602b9d6

3 files changed

+12
-6
lines changed

test/parallel/test-http2-https-fallback.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ function onSession(session, next) {
151151
// Incompatible ALPN TLS client
152152
tls(Object.assign({ port, ALPNProtocols: ['fake'] }, clientOptions))
153153
.on('error', common.mustCall((err) => {
154-
strictEqual(err.code, 'ECONNRESET');
154+
const allowedErrors = ['ECONNRESET', 'ERR_SSL_TLSV1_ALERT_NO_APPLICATION_PROTOCOL'];
155+
ok(allowedErrors.includes(err.code), `'${err.code}' was not one of ${allowedErrors}.`);
155156
cleanup();
156157
testNoALPN();
157158
}));

test/parallel/test-http2-server-unknown-protocol.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ server.listen(0, function() {
4242
rejectUnauthorized: false,
4343
ALPNProtocols: ['bogus']
4444
}).on('error', common.mustCall((err) => {
45-
assert.strictEqual(err.code, 'ECONNRESET');
45+
const allowedErrors = ['ECONNRESET', 'ERR_SSL_TLSV1_ALERT_NO_APPLICATION_PROTOCOL'];
46+
assert.ok(allowedErrors.includes(err.code), `'${err.code}' was not one of ${allowedErrors}.`);
4647
}));
4748
});

test/parallel/test-tls-alpn-server-client.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,17 @@ function TestFatalAlert() {
184184
server.listen(0, serverIP, common.mustCall(() => {
185185
const { port } = server.address();
186186

187-
// The Node.js client will just report ECONNRESET because the connection
187+
// The Node.js client will just report ECONNRESET (older OpenSSL) or
188+
// ERR_SSL_TLSV1_ALERT_NO_APPLICATION_PROTOCOL because the connection
188189
// is severed before the TLS handshake completes.
189190
tls.connect({
190191
host: serverIP,
191192
port,
192193
rejectUnauthorized: false,
193194
ALPNProtocols: ['bar']
194195
}, common.mustNotCall()).on('error', common.mustCall((err) => {
195-
assert.strictEqual(err.code, 'ECONNRESET');
196+
const allowedErrors = ['ECONNRESET', 'ERR_SSL_TLSV1_ALERT_NO_APPLICATION_PROTOCOL'];
197+
assert.ok(allowedErrors.includes(err.code), `'${err.code}' was not one of ${allowedErrors}.`);
196198

197199
// OpenSSL's s_client should output the TLS alert number, which is 120
198200
// for the 'no_application_protocol' alert.
@@ -240,7 +242,8 @@ function TestALPNCallback() {
240242

241243
// Callback picks 2nd preference => undefined => ALPN rejected:
242244
assert.strictEqual(results[1].server, undefined);
243-
assert.strictEqual(results[1].client.error.code, 'ECONNRESET');
245+
const allowedErrors = ['ECONNRESET', 'ERR_SSL_TLSV1_ALERT_NO_APPLICATION_PROTOCOL'];
246+
assert.ok(allowedErrors.includes(results[1].client.error.code), `'${results[1].client.error.code}' was not one of ${allowedErrors}.`);
244247

245248
TestBadALPNCallback();
246249
});
@@ -263,7 +266,8 @@ function TestBadALPNCallback() {
263266
runTest(clientsOptions, serverOptions, function(results) {
264267
// Callback returns 'http/5' => doesn't match client ALPN => error & reset
265268
assert.strictEqual(results[0].server, undefined);
266-
assert.strictEqual(results[0].client.error.code, 'ECONNRESET');
269+
const allowedErrors = ['ECONNRESET', 'ERR_SSL_TLSV1_ALERT_NO_APPLICATION_PROTOCOL'];
270+
assert.ok(allowedErrors.includes(results[0].client.error.code), `'${results[0].client.error.code}' was not one of ${allowedErrors}.`);
267271

268272
TestALPNOptionsCallback();
269273
});

0 commit comments

Comments
 (0)