trivial tests fixes for OpenSSL32 compatibility
authorJérémy Lal <kapouer@melix.org>
Tue, 25 Jun 2024 10:57:00 +0000 (12:57 +0200)
committerJérémy Lal <kapouer@melix.org>
Tue, 25 Jun 2024 10:57:00 +0000 (12:57 +0200)
Forwarded: https://github.com/nodejs/node/issues/51152
Last-Update: 2024-04-11

Gbp-Pq: Topic build
Gbp-Pq: Name openssl_32.patch

13 files changed:
test/common/index.js
test/parallel/test-crypto-rsa-dsa.js
test/parallel/test-tls-alert-handling.js
test/parallel/test-tls-client-auth.js
test/parallel/test-tls-empty-sni-context.js
test/parallel/test-tls-enable-trace-cli.js
test/parallel/test-tls-enable-trace.js
test/parallel/test-tls-getcipher.js
test/parallel/test-tls-junk-closes-server.js
test/parallel/test-tls-junk-server.js
test/parallel/test-tls-psk-circuit.js
test/parallel/test-tls-set-ciphers.js
test/sequential/sequential.status

index 6ef229797c8f77788428316c5bd566bdb7c9bd56..4d78f3b363a8a170e19eda1c7e95c4758be508e2 100644 (file)
@@ -63,6 +63,9 @@ const hasOpenSSL3 = hasCrypto &&
 const hasOpenSSL31 = hasCrypto &&
     require('crypto').constants.OPENSSL_VERSION_NUMBER >= 0x30100000;
 
+const hasOpenSSL32 = hasCrypto &&
+    require('crypto').constants.OPENSSL_VERSION_NUMBER >= 0x30200000;
+
 const hasQuic = hasCrypto && !!process.config.variables.openssl_quic;
 
 function parseTestFlags(filename = process.argv[1]) {
@@ -967,6 +970,7 @@ const common = {
   hasCrypto,
   hasOpenSSL3,
   hasOpenSSL31,
+  hasOpenSSL32,
   hasQuic,
   hasMultiLocalhost,
   invalidArgTypeHelper,
index 5f4fafdfffbf726b7cb39c472baa3df25c9794cf..b07e02601b99665e2a83000294bf0fab7323300f 100644 (file)
@@ -222,7 +222,7 @@ function test_rsa(padding, encryptOaepHash, decryptOaepHash) {
   }, bufferToEncrypt);
 
 
-  if (padding === constants.RSA_PKCS1_PADDING) {
+  if (padding === constants.RSA_PKCS1_PADDING && !common.hasOpenSSL32) {
     if (!process.config.variables.node_shared_openssl) {
       assert.throws(() => {
         crypto.privateDecrypt({
index bd86149bc5ac228a65586b3523580cb1cce01488..89b38c8df278801f70546209adabffc962fbc770 100644 (file)
@@ -31,10 +31,10 @@ const max_iter = 20;
 let iter = 0;
 
 const errorHandler = common.mustCall((err) => {
-  assert.strictEqual(err.code, 'ERR_SSL_WRONG_VERSION_NUMBER');
+  assert.strictEqual(err.code, common.hasOpenSSL32 ? 'ERR_SSL_PACKET_LENGTH_TOO_LONG' : 'ERR_SSL_WRONG_VERSION_NUMBER');
   assert.strictEqual(err.library, 'SSL routines');
   if (!common.hasOpenSSL3) assert.strictEqual(err.function, 'ssl3_get_record');
-  assert.strictEqual(err.reason, 'wrong version number');
+  assert.strictEqual(err.reason, common.hasOpenSSL32 ? 'packet length too long' : 'wrong version number');
   errorReceived = true;
   if (canCloseServer())
     server.close();
@@ -87,10 +87,10 @@ function sendBADTLSRecord() {
     });
   }));
   client.on('error', common.mustCall((err) => {
-    assert.strictEqual(err.code, 'ERR_SSL_TLSV1_ALERT_PROTOCOL_VERSION');
+    assert.strictEqual(err.code, common.hasOpenSSL32 ? 'ERR_SSL_TLSV1_ALERT_RECORD_OVERFLOW' : 'ERR_SSL_TLSV1_ALERT_PROTOCOL_VERSION');
     assert.strictEqual(err.library, 'SSL routines');
     if (!common.hasOpenSSL3)
       assert.strictEqual(err.function, 'ssl3_read_bytes');
-    assert.strictEqual(err.reason, 'tlsv1 alert protocol version');
+    assert.strictEqual(err.reason, common.hasOpenSSL32 ? 'tlsv1 alert record overflow' : 'tlsv1 alert protocol version');
   }));
 }
index 04756924e5e0e6d09dfb5c7c4419adacd8d27e2d..0a2d36d657946c77cd740aa689641fd9c169e1f0 100644 (file)
@@ -80,7 +80,7 @@ connect({
   assert.strictEqual(pair.server.err.code,
                      'ERR_SSL_PEER_DID_NOT_RETURN_A_CERTIFICATE');
   assert.strictEqual(pair.client.err.code,
-                     'ERR_SSL_SSLV3_ALERT_HANDSHAKE_FAILURE');
+                     common.hasOpenSSL32 ? 'ERR_SSL_SSL/TLS_ALERT_HANDSHAKE_FAILURE' : 'ERR_SSL_SSLV3_ALERT_HANDSHAKE_FAILURE');
   return cleanup();
 });
 
index 87219976a1ebda3b8de252c514ab4446efea53dd..0a0105b655ebbd5fd38be37ee6660e4d2839f2fb 100644 (file)
@@ -26,6 +26,6 @@ const server = tls.createServer(options, (c) => {
   }, common.mustNotCall());
 
   c.on('error', common.mustCall((err) => {
-    assert.strictEqual(err.code, 'ERR_SSL_SSLV3_ALERT_HANDSHAKE_FAILURE');
+    assert.strictEqual(err.code, common.hasOpenSSL32 ? 'ERR_SSL_SSL/TLS_ALERT_HANDSHAKE_FAILURE' : 'ERR_SSL_SSLV3_ALERT_HANDSHAKE_FAILURE');
   }));
 }));
index 7b6f7e22397af6418a82f03e36c4333537a5f599..414427fd603625274973daec1ef014534081a1d3 100644 (file)
@@ -36,7 +36,7 @@ child.on('close', common.mustCall((code, signal) => {
   assert.strictEqual(signal, null);
   assert.strictEqual(stdout.trim(), '');
   assert.match(stderr, /Warning: Enabling --trace-tls can expose sensitive/);
-  assert.match(stderr, /Sent Record/);
+  assert.match(stderr, /Sent (TLS )?Record/);
 }));
 
 function test() {
index 9126f58ee17314ae844ab99accdc126fb8970e0f..d4f3bcee8184c5735358b620d8f56f8f5bcdec8f 100644 (file)
@@ -23,7 +23,7 @@ let stderr = '';
 child.stderr.setEncoding('utf8');
 child.stderr.on('data', (data) => stderr += data);
 child.on('close', common.mustCall(() => {
-  assert.match(stderr, /Received Record/);
+  assert.match(stderr, /Received (TLS )?Record/);
   assert.match(stderr, /ClientHello/);
 }));
 
index 2a234d59016c1cf05aa04809e485923e5f6a3cbd..88e44e2ee5b9785b5a7b050527871bb7d449bada 100644 (file)
@@ -25,6 +25,9 @@ const common = require('../common');
 if (!common.hasCrypto)
   common.skip('missing crypto');
 
+if (common.hasOpenSSL32)
+  common.skip('test not compatible with openssl 3.2')
+
 const assert = require('assert');
 const tls = require('tls');
 // Import fixtures directly from its module
index 06fa57267a9104c44a0496e199fb51bda25f4fe2..8b5d2b51eb11b183f4a234c291806156790eb7c9 100644 (file)
@@ -26,6 +26,9 @@ const fixtures = require('../common/fixtures');
 if (!common.hasCrypto)
   common.skip('missing crypto');
 
+if (common.hasOpenSSL32)
+  common.skip('openssl 3.2 does not throw');
+
 const tls = require('tls');
 const net = require('net');
 
index 273fe9def4ecb48cbde8a2f8b88c1468c2d5faaf..3c9de38e014c203f0f2ca9d65e57436d27f4dd87 100644 (file)
@@ -21,7 +21,7 @@ server.listen(0, function() {
   req.end();
 
   req.once('error', common.mustCall(function(err) {
-    assert(/wrong version number/.test(err.message));
+    assert(/packet length too long/.test(err.message));
     server.close();
   }));
 });
index cef6735032ea6ebd5a400fd437c7dc239cdb395d..6f23acd55cda42f2beb4497703122c513175317d 100644 (file)
@@ -63,8 +63,8 @@ test({ psk: USERS.UserB, identity: 'UserB' });
 test({ psk: USERS.UserB, identity: 'UserB' }, { minVersion: 'TLSv1.3' });
 // Unrecognized user should fail handshake
 test({ psk: USERS.UserB, identity: 'UserC' }, {},
-     'ERR_SSL_SSLV3_ALERT_HANDSHAKE_FAILURE');
+     common.hasOpenSSL32 ? 'ERR_SSL_SSL/TLS_ALERT_HANDSHAKE_FAILURE' : 'ERR_SSL_SSLV3_ALERT_HANDSHAKE_FAILURE');
 // Recognized user but incorrect secret should fail handshake
 test({ psk: USERS.UserA, identity: 'UserB' }, {},
-     'ERR_SSL_SSLV3_ALERT_ILLEGAL_PARAMETER');
+     common.hasOpenSSL32 ? 'ERR_SSL_SSL/TLS_ALERT_ILLEGAL_PARAMETER' : 'ERR_SSL_SSLV3_ALERT_ILLEGAL_PARAMETER');
 test({ psk: USERS.UserB, identity: 'UserB' });
index 313c5e238956b06db70e512a92b45d72ed2da142..92dcff7661e2b5d785b95849bcc9486b97d19005 100644 (file)
@@ -3,6 +3,9 @@ const common = require('../common');
 if (!common.hasOpenSSL3)
   common.skip('missing crypto, or OpenSSL version lower than 3');
 
+if (common.hasOpenSSL32)
+  common.skip('openssl 3.2 does not support those ciphers - FIXME');
+
 const fixtures = require('../common/fixtures');
 const { inspect } = require('util');
 
@@ -89,13 +92,13 @@ test('TLS_AES_256_GCM_SHA384:!TLS_CHACHA20_POLY1305_SHA256', U, 'TLS_AES_256_GCM
 
 // Do not have shared ciphers.
 test('TLS_AES_256_GCM_SHA384', 'TLS_CHACHA20_POLY1305_SHA256',
-     U, 'ERR_SSL_SSLV3_ALERT_HANDSHAKE_FAILURE', 'ERR_SSL_NO_SHARED_CIPHER');
+     U, common.hasOpenSSL32 ? 'ERR_SSL_SSL/TLS_ALERT_HANDSHAKE_FAILURE' : 'ERR_SSL_SSLV3_ALERT_HANDSHAKE_FAILURE', 'ERR_SSL_NO_SHARED_CIPHER');
 
-test('AES128-SHA', 'AES256-SHA', U, 'ERR_SSL_SSLV3_ALERT_HANDSHAKE_FAILURE',
+test('AES128-SHA', 'AES256-SHA', U, common.hasOpenSSL32 ? 'ERR_SSL_SSL/TLS_ALERT_HANDSHAKE_FAILURE' : 'ERR_SSL_SSLV3_ALERT_HANDSHAKE_FAILURE',
      'ERR_SSL_NO_SHARED_CIPHER');
 test('AES128-SHA:TLS_AES_256_GCM_SHA384',
      'TLS_CHACHA20_POLY1305_SHA256:AES256-SHA',
-     U, 'ERR_SSL_SSLV3_ALERT_HANDSHAKE_FAILURE', 'ERR_SSL_NO_SHARED_CIPHER');
+     U, common.hasOpenSSL32 ? 'ERR_SSL_SSL/TLS_ALERT_HANDSHAKE_FAILURE' : 'ERR_SSL_SSLV3_ALERT_HANDSHAKE_FAILURE', 'ERR_SSL_NO_SHARED_CIPHER');
 
 // Cipher order ignored, TLS1.3 chosen before TLS1.2.
 test('AES256-SHA:TLS_AES_256_GCM_SHA384', U, 'TLS_AES_256_GCM_SHA384');
@@ -111,7 +114,7 @@ test(U, 'AES256-SHA', 'TLS_AES_256_GCM_SHA384', U, U, { maxVersion: 'TLSv1.3' })
 // TLS_AES_128_CCM_8_SHA256 & TLS_AES_128_CCM_SHA256 are not enabled by
 // default, but work.
 test('TLS_AES_128_CCM_8_SHA256', U,
-     U, 'ERR_SSL_SSLV3_ALERT_HANDSHAKE_FAILURE', 'ERR_SSL_NO_SHARED_CIPHER');
+     U, common.hasOpenSSL32 ? 'ERR_SSL_SSL/TLS_ALERT_HANDSHAKE_FAILURE' : 'ERR_SSL_SSLV3_ALERT_HANDSHAKE_FAILURE', 'ERR_SSL_NO_SHARED_CIPHER');
 
 test('TLS_AES_128_CCM_8_SHA256', 'TLS_AES_128_CCM_8_SHA256',
      'TLS_AES_128_CCM_8_SHA256');
index ccab879b6e5fcdcc0d3a4b790b97db94d92f1a59..746962f9b18152b01e6008b295f24b9f37a2fc93 100644 (file)
@@ -13,6 +13,9 @@ test-watch-mode-inspect: PASS, FLAKY
 # https://github.com/nodejs/node/issues/47409
 test-http2-large-file: PASS, FLAKY
 
+# fails on arm64, armhf, loong64 since openssl32
+test-tls-session-timeout: PASS, FLAKY
+
 [$system==win32]
 # https://github.com/nodejs/node/issues/47116
 test-http-max-sockets: PASS, FLAKY