From f327b2de6700d418373d9f64d6b2b23fc1e798f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Josef=20=C5=A0pa=C4=8Dek?= Date: Fri, 23 Jul 2021 12:39:55 +0200 Subject: [PATCH] Fix of callback count after openssl 3.0.0-alpha16 Related: rhbz#1985255 In OpenSSL between alpha16 and alpha17 was change (7bc027d73bc51cfa0ae23fbfd91134be9464d694) which add one callback call in case of failing pem_read_bio_key_decoder() --- ...SLeay-1.90-openssl3.0.0-05_passwd_cb.patch | 80 +++++++++++++++++++ perl-Net-SSLeay.spec | 5 ++ 2 files changed, 85 insertions(+) create mode 100644 Net-SSLeay-1.90-openssl3.0.0-05_passwd_cb.patch diff --git a/Net-SSLeay-1.90-openssl3.0.0-05_passwd_cb.patch b/Net-SSLeay-1.90-openssl3.0.0-05_passwd_cb.patch new file mode 100644 index 0000000..a723bc7 --- /dev/null +++ b/Net-SSLeay-1.90-openssl3.0.0-05_passwd_cb.patch @@ -0,0 +1,80 @@ +From e5a24498cb5294985b526ae1697fb3c10022573e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michal=20Josef=20=C5=A0pa=C4=8Dek?= +Date: Fri, 23 Jul 2021 12:21:10 +0200 +Subject: [PATCH] Fix of callback count after openssl 3.0.0-alpha16 + +In OpenSSL between alpha16 and alpha17 was change +(7bc027d73bc51cfa0ae23fbfd91134be9464d694) +which add one callback call in case of failing +pem_read_bio_key_decoder() +--- + t/local/05_passwd_cb.t | 41 ++++++++++++++++++++++++++++++++++++++--- + 1 file changed, 38 insertions(+), 3 deletions(-) + +diff --git a/t/local/05_passwd_cb.t b/t/local/05_passwd_cb.t +index 878e2aa..7c45fad 100644 +--- a/t/local/05_passwd_cb.t ++++ b/t/local/05_passwd_cb.t +@@ -5,7 +5,12 @@ use lib 'inc'; + use Net::SSLeay; + use Test::Net::SSLeay qw( data_file_path initialise_libssl ); + +-plan tests => 36; ++my $callback_double_use_in_pem_read_bio_key = check_callback_double_use_in_pem_read_bio_key(); ++if (! $callback_double_use_in_pem_read_bio_key) { ++ plan tests => 36; ++} else { ++ plan tests => 40; ++} + + initialise_libssl(); + +@@ -99,7 +104,13 @@ $key_password = 'incorrect'; + ok( !Net::SSLeay::CTX_use_PrivateKey_file($ctx_1, $key_pem, &Net::SSLeay::FILETYPE_PEM), + 'CTX_use_PrivateKey_file doesn\'t work with wrong passphrase' ); + +-is($cb_1_calls, 2, 'callback1 called 2 times'); ++my $right_cb_1_calls; ++if (! $callback_double_use_in_pem_read_bio_key) { ++ $right_cb_1_calls = 2; ++} else { ++ $right_cb_1_calls = 3; ++} ++is($cb_1_calls, $right_cb_1_calls, 'callback1 called '.$right_cb_1_calls.' times'); + + + # OpenSSL 1.1.0 has SSL_set_default_passwd_cb, but the callback is not +@@ -177,5 +188,29 @@ sub test_ssl_funcs + ok( !Net::SSLeay::use_PrivateKey_file($ssl_1, $key_pem, &Net::SSLeay::FILETYPE_PEM), + 'use_PrivateKey_file doesn\'t work with wrong passphrase' ); + +- is($cb_1_calls, 2, 'callback1 called 2 times'); ++ my $right_cb_1_calls; ++ if (! $callback_double_use_in_pem_read_bio_key) { ++ $right_cb_1_calls = 2; ++ } else { ++ $right_cb_1_calls = 3; ++ } ++ ++ is($cb_1_calls, $right_cb_1_calls, 'callback1 called '.$right_cb_1_calls.' times'); ++} ++ ++# In OpenSSL between alpha16 and alpha17 was change (7bc027d73bc51cfa0ae23fbfd91134be9464d694) ++# which add one callback call in case of failing pem_read_bio_key_decoder() ++sub check_callback_double_use_in_pem_read_bio_key { ++ my $ssleay_version = Net::SSLeay::SSLeay_version( Net::SSLeay::SSLEAY_VERSION() ); ++ my $openssl_alpha_version; ++ if (Net::SSLeay::SSLeay == 0x30000000 && $ssleay_version =~ /-alpha(\d+)\ /) { ++ $openssl_alpha_version = $1; ++ } ++ if ((Net::SSLeay::SSLeay == 0x30000000 && defined $openssl_alpha_version && $openssl_alpha_version < 17) ++ || Net::SSLeay::SSLeay < 0x30000000) { ++ ++ return 0; ++ } else { ++ return 1; ++ } + } +-- +2.31.1 + diff --git a/perl-Net-SSLeay.spec b/perl-Net-SSLeay.spec index 804d78b..4766c06 100644 --- a/perl-Net-SSLeay.spec +++ b/perl-Net-SSLeay.spec @@ -17,6 +17,7 @@ Patch12: Net-SSLeay-1.90-openssl3.0.0-33_x509_create_cert.patch Patch13: Net-SSLeay-1.90-openssl3.0.0-39_pkcs12.patch Patch14: Net-SSLeay-1.90-openssl3.0.0-43_misc_functions.patch Patch15: Net-SSLeay-1.90-openssl3.0.0-tests-disable_TLS1_and_TLS1_1.patch +Patch16: Net-SSLeay-1.90-openssl3.0.0-05_passwd_cb.patch # =========== Module Build =========================== BuildRequires: coreutils BuildRequires: findutils @@ -101,6 +102,9 @@ so you can write servers or clients for more complicated applications. # XXX Disable TLS1 and TLS1_1 from tests %patch15 -p1 +# https://github.com/radiator-software/p5-net-ssleay/pull/282 +%patch16 -p1 + # Fix permissions in examples to avoid bogus doc-file dependencies chmod -c 644 examples/* @@ -139,6 +143,7 @@ make test %changelog * Fri Jul 23 2021 Michal Josef Špaček - 1.90-6 - Fix tests for openssl 3.0.0-beta1. rhbz#1964854 + - Add fix for t/05_passwd_cb.t - Update Net-SSLeay-1.90-openssl3.0.0-43_misc_functions.patch to accept beta version - Fix tab vs space in spec file - Update Net-SSLeay-1.90-openssl3.0.0-39_pkcs12.patch patch to upstream version