From f68af45a303a3241e205e322af46f932ff2a3d3b Mon Sep 17 00:00:00 2001 From: Andrea Pappacoda Date: Tue, 17 Sep 2024 15:08:21 +0200 Subject: [PATCH] test(meson): fix SSLClientServerTest.* tests with OpenSSL 3.2.0 Since OpenSSL commit , the default X.509 certificate format generated with the `openssl req` command has been changed to X.509 v3 from X.509 v1. For some reason, this change breaks cpp-httplib's SSLClientServerTest.* tests. To fix the test failures, this patch passes the '-x509v1' flag instead of '-x509' when OpenSSL 3.2.0 or newer is detected. To detect the version of a command line utility, Meson 0.62.0 or later is required. Fixes , but only for the Meson build system. --- test/meson.build | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/meson.build b/test/meson.build index de391a0310..e7819dbfb6 100644 --- a/test/meson.build +++ b/test/meson.build @@ -6,6 +6,7 @@ gtest_dep = dependency('gtest', main: true) libcurl_dep = dependency('libcurl') openssl = find_program('openssl') test_conf = files('test.conf') +req_x509_flag = openssl.version().version_compare('>=3.2.0') ? '-x509v1' : '-x509' key_pem = custom_target( 'key_pem', @@ -31,7 +32,7 @@ cert2_pem = custom_target( 'cert2_pem', input: key_pem, output: 'cert2.pem', - command: [openssl, 'req', '-x509', '-config', test_conf, '-key', '@INPUT@', '-sha256', '-days', '3650', '-nodes', '-out', '@OUTPUT@', '-extensions', 'SAN'] + command: [openssl, 'req', req_x509_flag, '-config', test_conf, '-key', '@INPUT@', '-sha256', '-days', '3650', '-nodes', '-out', '@OUTPUT@', '-extensions', 'SAN'] ) key_encrypted_pem = custom_target( @@ -44,7 +45,7 @@ cert_encrypted_pem = custom_target( 'cert_encrypted_pem', input: key_encrypted_pem, output: 'cert_encrypted.pem', - command: [openssl, 'req', '-x509', '-config', test_conf, '-key', '@INPUT@', '-sha256', '-days', '3650', '-nodes', '-out', '@OUTPUT@', '-extensions', 'SAN'] + command: [openssl, 'req', req_x509_flag, '-config', test_conf, '-key', '@INPUT@', '-sha256', '-days', '3650', '-nodes', '-out', '@OUTPUT@', '-extensions', 'SAN'] ) rootca_key_pem = custom_target( @@ -57,7 +58,7 @@ rootca_cert_pem = custom_target( 'rootca_cert_pem', input: rootca_key_pem, output: 'rootCA.cert.pem', - command: [openssl, 'req', '-x509', '-new', '-batch', '-config', files('test.rootCA.conf'), '-key', '@INPUT@', '-days', '1024', '-out', '@OUTPUT@'] + command: [openssl, 'req', req_x509_flag, '-new', '-batch', '-config', files('test.rootCA.conf'), '-key', '@INPUT@', '-days', '1024', '-out', '@OUTPUT@'] ) client_key_pem = custom_target(