Skip to content

Commit 3bcbb3a

Browse files
authored
GH-86 Fix set_cert_and_key() return value handling. (#87)
Applied a patch to set_cert_and_key() from Damyan Ivanov, Debian Perl Group. set_cert_and_key() now returns errors from library's error stack only when a function it calls returns with failure. Previously any old and unrelated errors from the error stack were considered when setting up return values. This fixes RT#126988 and closes #86. For the full details, see https://rt.cpan.org/Ticket/Display.html?id=126988
1 parent 421feca commit 3bcbb3a

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Changes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ Revision history for Perl extension Net::SSLeay.
6262
Howarth. Add SSL_set_post_handshake_auth,
6363
SSL_verify_client_post_handshake and constant
6464
SSL_VERIFY_POST_HANDSHAKE.
65+
- Applied a patch to set_cert_and_key() from Damyan Ivanov,
66+
Debian Perl Group. This function now returns errors from
67+
library's error stack only when an underlying routine
68+
fails. Unrelated errors are now skipped. Fixes RT#126988.
6569
- Enhance t/local/43_misc_functions.t get_keyblock_size test
6670
to work better with AEAD ciphers.
6771
- Add constants SSL_OP_ENABLE_MIDDLEBOX_COMPAT and

lib/Net/SSLeay.pm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,10 +1289,10 @@ sub set_cert_and_key ($$$) {
12891289
my ($ctx, $cert_path, $key_path) = @_;
12901290
my $errs = '';
12911291
# Following will ask password unless private key is not encrypted
1292-
CTX_use_PrivateKey_file ($ctx, $key_path, &FILETYPE_PEM);
1293-
$errs .= print_errs("private key `$key_path' ($!)");
1294-
CTX_use_certificate_file ($ctx, $cert_path, &FILETYPE_PEM);
1295-
$errs .= print_errs("certificate `$cert_path' ($!)");
1292+
CTX_use_PrivateKey_file( $ctx, $key_path, &FILETYPE_PEM ) == 1
1293+
or $errs .= print_errs("private key `$key_path' ($!)");
1294+
CTX_use_certificate_file ($ctx, $cert_path, &FILETYPE_PEM) == 1
1295+
or $errs .= print_errs("certificate `$cert_path' ($!)");
12961296
return wantarray ? (undef, $errs) : ($errs eq '');
12971297
}
12981298

0 commit comments

Comments
 (0)