Skip to content

Commit a65105e

Browse files
authored
test: adjust tls test for OpenSSL32
Refs: nodejs#53382 Looks like test is forcing an error through bad data and the error code we get is different for OpenSSL32. Adjust test to cope with the variation across versions. Signed-off-by: Michael Dawson <midawson@redhat.com> PR-URL: nodejs#54909 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent c6f514c commit a65105e

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

test/parallel/test-tls-alert-handling.js

+17-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,17 @@ const max_iter = 20;
3131
let iter = 0;
3232

3333
const errorHandler = common.mustCall((err) => {
34-
assert.strictEqual(err.code, 'ERR_SSL_WRONG_VERSION_NUMBER');
34+
let expectedErrorCode = 'ERR_SSL_WRONG_VERSION_NUMBER';
35+
let expectedErrorReason = 'wrong version number';
36+
if (common.hasOpenSSL(3, 2)) {
37+
expectedErrorCode = 'ERR_SSL_PACKET_LENGTH_TOO_LONG';
38+
expectedErrorReason = 'packet length too long';
39+
};
40+
41+
assert.strictEqual(err.code, expectedErrorCode);
3542
assert.strictEqual(err.library, 'SSL routines');
3643
if (!common.hasOpenSSL3) assert.strictEqual(err.function, 'ssl3_get_record');
37-
assert.strictEqual(err.reason, 'wrong version number');
44+
assert.strictEqual(err.reason, expectedErrorReason);
3845
errorReceived = true;
3946
if (canCloseServer())
4047
server.close();
@@ -87,10 +94,16 @@ function sendBADTLSRecord() {
8794
});
8895
}));
8996
client.on('error', common.mustCall((err) => {
90-
assert.strictEqual(err.code, 'ERR_SSL_TLSV1_ALERT_PROTOCOL_VERSION');
97+
let expectedErrorCode = 'ERR_SSL_TLSV1_ALERT_PROTOCOL_VERSION';
98+
let expectedErrorReason = 'tlsv1 alert protocol version';
99+
if (common.hasOpenSSL(3, 2)) {
100+
expectedErrorCode = 'ERR_SSL_TLSV1_ALERT_RECORD_OVERFLOW';
101+
expectedErrorReason = 'tlsv1 alert record overflow';
102+
}
103+
assert.strictEqual(err.code, expectedErrorCode);
91104
assert.strictEqual(err.library, 'SSL routines');
92105
if (!common.hasOpenSSL3)
93106
assert.strictEqual(err.function, 'ssl3_read_bytes');
94-
assert.strictEqual(err.reason, 'tlsv1 alert protocol version');
107+
assert.strictEqual(err.reason, expectedErrorReason);
95108
}));
96109
}

0 commit comments

Comments
 (0)