| 1 | # vim: set sts=4 sw=4 ts=8 ai: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # IO::Socket::SSL: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # provide an interface to SSL connections similar to IO::Socket modules | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # Current Code Shepherd: Steffen Ullrich <sullr at cpan.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # Code Shepherd before: Peter Behroozi, <behrooz at fas.harvard.edu> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # The original version of this module was written by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # Marko Asplund, <marko.asplund at kronodoc.fi>, who drew from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # Crypt::SSLeay (Net::SSL) by Gisle Aas. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | package IO::Socket::SSL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 26 | our $VERSION = '2.005'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 26 | ▶ | use IO::Socket; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 26 | ▶ | use Net::SSLeay 1.46; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 26 | ▶ | use IO::Socket::SSL::PublicSuffix; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 26 | ▶ | use Exporter (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 26 | ▶ | use Errno qw( EAGAIN ETIMEDOUT ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 26 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 26 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 26 | eval { require Scalar::Util; Scalar::Util->import("weaken"); 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 26 | ▶ | || eval { require WeakRef; WeakRef->import("weaken"); 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=17.3
Branch: 1 branch
Condition33%1/3
eval {
do {
require Scalar::Util;
"Scalar::Util"->import("weaken");
1
}
} or eval {
do {
require WeakRef;
"WeakRef"->import("weaken");
1
}
}
MC/DC0%0/2
eval {
do {
require Scalar::Util;
"Scalar::Util"->import("weaken");
1
}
} or eval {
do {
require WeakRef;
"WeakRef"->import("weaken");
1
}
}
eval {
do {
require Scalar::Util;
"Scalar::Util"->import("weaken");
1
}
}
eval {
do {
require WeakRef;
"WeakRef"->import("weaken");
1
}
}
Truth table33%1/3
A or B
A= eval {
do {
require Scalar::Util;
"Scalar::Util"->import("weaken");
1
}
}B= eval {
do {
require WeakRef;
"WeakRef"->import("weaken");
1
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | || die "no support for weaken - please install Scalar::Util"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 26 | ▶ | use constant SSL_VERIFY_NONE => Net::SSLeay::VERIFY_NONE(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 26 | ▶ | use constant SSL_VERIFY_PEER => Net::SSLeay::VERIFY_PEER(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 26 | ▶ | use constant SSL_VERIFY_FAIL_IF_NO_PEER_CERT => Net::SSLeay::VERIFY_FAIL_IF_NO_PEER_CERT(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 26 | ▶ | use constant SSL_VERIFY_CLIENT_ONCE => Net::SSLeay::VERIFY_CLIENT_ONCE(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # from openssl/ssl.h; should be better in Net::SSLeay | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 26 | ▶ | use constant SSL_SENT_SHUTDOWN => 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 26 | ▶ | use constant SSL_RECEIVED_SHUTDOWN => 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 26 | ▶ | use constant SSL_OCSP_NO_STAPLE => 0b00001; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 26 | ▶ | use constant SSL_OCSP_MUST_STAPLE => 0b00010; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 26 | ▶ | use constant SSL_OCSP_FAIL_HARD => 0b00100; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 26 | ▶ | use constant SSL_OCSP_FULL_CHAIN => 0b01000; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 26 | ▶ | use constant SSL_OCSP_TRY_STAPLE => 0b10000; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # capabilities of underlying Net::SSLeay/openssl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 26 | my $can_client_sni; # do we support SNI on the client side | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | my $can_server_sni; # do we support SNI on the server side | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 26 | my $can_npn; # do we support NPN | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 26 | my $can_ecdh; # do we support ECDH key exchange | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 26 | my $can_ocsp; # do we support OCSP | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 26 | my $can_ocsp_staple; # do we support OCSP stapling | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 26 | ▶ | $can_client_sni = Net::SSLeay::OPENSSL_VERSION_NUMBER() >= 0x01000000; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=4 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 26 | $can_server_sni = defined &Net::SSLeay::get_servername; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 26 | $can_npn = defined &Net::SSLeay::P_next_proto_negotiated; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 26 | ▶ | $can_ecdh = defined &Net::SSLeay::CTX_set_tmp_ecdh && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
defined &Net::SSLeay::CTX_set_tmp_ecdh && (Net::SSLeay::OPENSSL_VERSION_NUMBER() != 268439631 || length pack('P', 0) == 4)
Net::SSLeay::OPENSSL_VERSION_NUMBER() != 268439631 or length pack("P", 0) == 4
MC/DC0%0/3
defined &Net::SSLeay::CTX_set_tmp_ecdh && (Net::SSLeay::OPENSSL_VERSION_NUMBER() != 268439631 || length pack('P', 0) == 4)
defined &Net::SSLeay::CTX_set_tmp_ecdh
Net::SSLeay::OPENSSL_VERSION_NUMBER() != 268439631
length pack("P", 0) == 4
Truth table25%1/4
A && B or C
A= defined &Net::SSLeay::CTX_set_tmp_ecdhB= Net::SSLeay::OPENSSL_VERSION_NUMBER() != 268439631C= length pack("P", 0) == 4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | # There is a regression with elliptic curves on 1.0.1d with 64bit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # http://rt.openssl.org/Ticket/Display.html?id=2975 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | ( Net::SSLeay::OPENSSL_VERSION_NUMBER() != 0x1000104f | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | || length(pack("P",0)) == 4 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 26 | $can_ocsp = defined &Net::SSLeay::OCSP_cert2ids; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 26 | ▶ | $can_ocsp_staple = $can_ocsp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$can_ocsp && defined &Net::SSLeay::set_tlsext_status_type
MC/DC0%0/2
$can_ocsp && defined &Net::SSLeay::set_tlsext_status_type
$can_ocsp
defined &Net::SSLeay::set_tlsext_status_type
Truth table33%1/3
A && B
A= $can_ocspB= defined &Net::SSLeay::set_tlsext_status_type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | && defined &Net::SSLeay::set_tlsext_status_type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 26 | my $algo2digest = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 26 | my %digest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 4 | ▶ | my $digest_name = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 4 | ▶ | return $digest{$digest_name} ||= do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$digest{$digest_name} ||= do {
&Net::SSLeay::SSLeay_add_ssl_algorithms();
&Net::SSLeay::EVP_get_digestbyname($digest_name) or die "Digest algorithm $digest_name is not available"
}
MC/DC0%0/2
$digest{$digest_name} ||= do {
&Net::SSLeay::SSLeay_add_ssl_algorithms();
&Net::SSLeay::EVP_get_digestbyname($digest_name) or die "Digest algorithm $digest_name is not available"
}
$digest{$digest_name}
do {
&Net::SSLeay::SSLeay_add_ssl_algorithms();
&Net::SSLeay::EVP_get_digestbyname($digest_name) or die "Digest algorithm $digest_name is not available"
}
Truth table66%2/3
A ||= B
A= $digest{$digest_name}B= do {
&Net::SSLeay::SSLeay_add_ssl_algorithms();
&Net::SSLeay::EVP_get_digestbyname($digest_name) or die "Digest algorithm $digest_name is not available"
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 2 | Net::SSLeay::SSLeay_add_ssl_algorithms(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 2 | ▶ | Net::SSLeay::EVP_get_digestbyname($digest_name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | or die "Digest algorithm $digest_name is not available"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 26 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # global defaults | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 26 | my %DEFAULT_SSL_ARGS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | SSL_check_crl => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | SSL_version => 'SSLv23:!SSLv3:!SSLv2', # consider both SSL3.0 and SSL2.0 as broken | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | SSL_verify_callback => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | SSL_verifycn_scheme => undef, # fallback cn verification | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | SSL_verifycn_publicsuffix => undef, # fallback default list verification | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | #SSL_verifycn_name => undef, # use from PeerAddr/PeerHost - do not override in set_args_filter_hack 'use_defaults' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | SSL_npn_protocols => undef, # meaning depends whether on server or client side | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | SSL_cipher_list => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 'EECDH+AESGCM+ECDSA EECDH+AESGCM EECDH+ECDSA +AES256 EECDH EDH+AESGCM '. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 'EDH ALL +SHA +3DES +RC4 !LOW !EXP !eNULL !aNULL !DES !MD5 !PSK !SRP', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 26 | my %DEFAULT_SSL_CLIENT_ARGS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | %DEFAULT_SSL_ARGS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | SSL_verify_mode => SSL_VERIFY_PEER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | SSL_ca_file => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | SSL_ca_path => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # older versions of F5 BIG-IP hang when getting SSL client hello >255 bytes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # http://support.f5.com/kb/en-us/solutions/public/13000/000/sol13037.html | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # http://guest:guest@rt.openssl.org/Ticket/Display.html?id=2771 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # Debian works around this by disabling TLSv1_2 on the client side | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # Chrome and IE11 use TLSv1_2 but use only a few ciphers, so that packet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # stays small enough | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # The following list is taken from IE11, except that we don't do RC4-MD5, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | # RC4-SHA is already bad enough. Also, we have a different sort order | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | # compared to IE11, because we put ciphers supporting forward secrecy on top | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | SSL_cipher_list => join(" ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | ECDHE-ECDSA-AES128-GCM-SHA256 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | ECDHE-ECDSA-AES128-SHA256 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | ECDHE-ECDSA-AES256-GCM-SHA384 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | ECDHE-ECDSA-AES256-SHA384 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | ECDHE-ECDSA-AES128-SHA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | ECDHE-ECDSA-AES256-SHA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | ECDHE-RSA-AES128-SHA256 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | ECDHE-RSA-AES128-SHA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | ECDHE-RSA-AES256-SHA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | DHE-DSS-AES128-SHA256 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | DHE-DSS-AES128-SHA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | DHE-DSS-AES256-SHA256 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | DHE-DSS-AES256-SHA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | AES128-SHA256 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | AES128-SHA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | AES256-SHA256 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | AES256-SHA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | EDH-DSS-DES-CBC3-SHA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | DES-CBC3-SHA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | RC4-SHA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | # just to make sure, that we don't accidentely add bad ciphers above | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | "!EXP !LOW !eNULL !aNULL !DES !MD5 !PSK !SRP" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | # set values inside _init to work with perlcc, RT#95452 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 26 | my %DEFAULT_SSL_SERVER_ARGS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | # Initialization of OpenSSL internals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | # This will be called once during compilation - perlcc users might need to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | # call it again by hand, see RT#95452 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 26 | sub init { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | # library_init returns false if the library was already initialized. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | # This way we can find out if the library needs to be re-initialized | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | # inside code compiled with perlcc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 51 | ▶ | Net::SSLeay::library_init() or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=4 SCAR=13.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 26 | Net::SSLeay::load_error_strings(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 26 | Net::SSLeay::OpenSSL_add_all_digests(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 26 | Net::SSLeay::randomize(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | %DEFAULT_SSL_SERVER_ARGS = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | %DEFAULT_SSL_ARGS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | SSL_verify_mode => SSL_VERIFY_NONE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | SSL_honor_cipher_order => 1, # trust server to know the best cipher | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 26 | SSL_dh => do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 26 | my $bio = Net::SSLeay::BIO_new(Net::SSLeay::BIO_s_mem()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | # generated with: openssl dhparam 2048 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 26 | Net::SSLeay::BIO_write($bio,<<'DH'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | -----BEGIN DH PARAMETERS----- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | MIIBCAKCAQEAr8wskArj5+1VCVsnWt/RUR7tXkHJ7mGW7XxrLSPOaFyKyWf8lZht | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | iSY2Lc4oa4Zw8wibGQ3faeQu/s8fvPq/aqTxYmyHPKCMoze77QJHtrYtJAosB9SY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | CN7s5Hexxb5/vQ4qlQuOkVrZDiZO9GC4KaH9mJYnCoAsXDhDft6JT0oRVSgtZQnU | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | gWFKShIm+JVjN94kGs0TcBEesPTK2g8XVHK9H8AtSUb9BwW2qD/T5RmgNABysApO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | Ps2vlkxjAHjJcqc3O+OiImKik/X2rtBTZjpKmzN3WWTB0RJZCOWaLlDO81D01o1E | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | aZecz3Np9KIYey900f+X7zC2bJxEHp95ywIBAg== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | -----END DH PARAMETERS----- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | DH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 26 | my $dh = Net::SSLeay::PEM_read_bio_DHparams($bio); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 26 | Net::SSLeay::BIO_free($bio); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 26 | ▶ | $dh or die "no DH"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 26 | ▶ | $dh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | $can_ecdh ? ( SSL_ecdh_curve => 'prime256v1' ):(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | # Call it once at compile time and try it at INIT. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # This should catch all cases of including the module, e.g 'use' (INIT) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | # 'require' (compile time) and works also with perlcc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 26 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 25 | ▶ | INIT { init() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
INIT: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 26 | init(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | # global defaults which can be changed using set_defaults | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | # either key/value can be set or it can just be set to an external hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 26 | my $GLOBAL_SSL_ARGS = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 26 | my $GLOBAL_SSL_CLIENT_ARGS = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 26 | my $GLOBAL_SSL_SERVER_ARGS = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | # hack which is used to filter bad settings from used modules | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 26 | my $FILTER_SSL_ARGS = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | # non-XS Versions of Scalar::Util will fail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | BEGIN{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 26 | ▶ | local $SIG{__DIE__}; local $SIG{__WARN__}; # be silent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 26 | ▶ | eval { use Scalar::Util 'dualvar'; dualvar(0,'') }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 26 | ▶ | die "You need the XS Version of Scalar::Util for dualvar() support" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # get constants for SSL_OP_NO_* now, instead calling the releated functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # every time we setup a connection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 26 | my %SSL_OP_NO; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 26 | for(qw( SSLv2 SSLv3 TLSv1 TLSv1_1 TLSv11:TLSv1_1 TLSv1_2 TLSv12:TLSv1_2 )) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 182 | ▶ | my ($k,$op) = m{:} ? split(m{:},$_,2) : ($_,$_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 182 | my $sub = "Net::SSLeay::OP_NO_$op"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 26 | ▶ | $SSL_OP_NO{$k} = eval { no strict 'refs'; &$sub } || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Condition100%2/2
eval {
do {
no strict 'refs';
&$sub
}
} || 0
MC/DC100%1/1
eval {
do {
no strict 'refs';
&$sub
}
} || 0
eval {
do {
no strict 'refs';
&$sub
}
}
Truth table100%2/2
A
A= eval {
do {
no strict 'refs';
&$sub
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | # Make SSL_CTX_clear_options accessible through SSL_CTX_ctrl unless it is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | # already implemented in Net::SSLeay | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 26 | ▶ | if (!defined &Net::SSLeay::CTX_clear_options) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | *Net::SSLeay::CTX_clear_options = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 1 | ▶ | my ($ctx,$opt) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | # 77 = SSL_CTRL_CLEAR_OPTIONS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 1 | Net::SSLeay::CTX_ctrl($ctx,77,$opt,0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 26 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 26 | our $DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 26 | ▶ | use vars qw(@ISA $SSL_ERROR @EXPORT); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | # These constants will be used in $! at return from SSL_connect, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # SSL_accept, _generic_(read|write), thus notifying the caller | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | # the usual way of problems. Like with EAGAIN, EINPROGRESS.. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | # these are especially important for non-blocking sockets | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 26 | my $x = Net::SSLeay::ERROR_WANT_READ(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 26 | ▶ | use constant SSL_WANT_READ => dualvar( \$x, 'SSL wants a read first' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 26 | my $y = Net::SSLeay::ERROR_WANT_WRITE(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 26 | ▶ | use constant SSL_WANT_WRITE => dualvar( \$y, 'SSL wants a write first' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 26 | @EXPORT = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | SSL_WANT_READ SSL_WANT_WRITE SSL_VERIFY_NONE SSL_VERIFY_PEER | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | SSL_VERIFY_FAIL_IF_NO_PEER_CERT SSL_VERIFY_CLIENT_ONCE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | SSL_OCSP_NO_STAPLE SSL_OCSP_TRY_STAPLE SSL_OCSP_MUST_STAPLE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | SSL_OCSP_FAIL_HARD SSL_OCSP_FULL_CHAIN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | $SSL_ERROR GEN_DNS GEN_IPADD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 26 | my @caller_force_inet4; # in case inet4 gets forced we store here who forced it | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | my $IOCLASS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | # declare @ISA depending of the installed socket class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # try to load inet_pton from Socket or Socket6 and make sure it is usable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 26 | ▶ | local $SIG{__DIE__}; local $SIG{__WARN__}; # be silent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=11 SCAR=28.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | my $ip6 = eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 26 | require Socket; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 26 | Socket->VERSION(1.95); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 26 | ▶ | my $ok = Socket::inet_pton( AF_INET6(),'::1') && AF_INET6(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
Socket::inet_pton(10, '::1') && 10
MC/DC0%0/1
Socket::inet_pton(10, '::1') && 10
Socket::inet_pton(10, '::1')
Truth table50%1/2
A
A= Socket::inet_pton(10, '::1')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 26 | ▶ | $ok && Socket->import( qw/inet_pton getnameinfo NI_NUMERICHOST NI_NUMERICSERV/ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 26 | $ok; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 26 | ▶ | } || eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
eval {
do {
require Socket;
'Socket'->VERSION(1.95);
my $ok = Socket::inet_pton(10, '::1') && 10;
$ok and 'Socket'->import('inet_pton', 'getnameinfo', 'NI_NUMERICHOST', 'NI_NUMERICSERV');
$ok
}
} || eval {
do {
require Socket6;
my $ok = Socket6::inet_pton(10, '::1') && 10;
$ok and 'Socket6'->import('inet_pton', 'getnameinfo', 'NI_NUMERICHOST', 'NI_NUMERICSERV');
$ok
}
}
MC/DC0%0/2
eval {
do {
require Socket;
'Socket'->VERSION(1.95);
my $ok = Socket::inet_pton(10, '::1') && 10;
$ok and 'Socket'->import('inet_pton', 'getnameinfo', 'NI_NUMERICHOST', 'NI_NUMERICSERV');
$ok
}
} || eval {
do {
require Socket6;
my $ok = Socket6::inet_pton(10, '::1') && 10;
$ok and 'Socket6'->import('inet_pton', 'getnameinfo', 'NI_NUMERICHOST', 'NI_NUMERICSERV');
$ok
}
}
eval {
do {
require Socket;
'Socket'->VERSION(1.95);
my $ok = Socket::inet_pton(10, '::1') && 10;
$ok and 'Socket'->import('inet_pton', 'getnameinfo', 'NI_NUMERICHOST', 'NI_NUMERICSERV');
$ok
}
}
eval {
do {
require Socket6;
my $ok = Socket6::inet_pton(10, '::1') && 10;
$ok and 'Socket6'->import('inet_pton', 'getnameinfo', 'NI_NUMERICHOST', 'NI_NUMERICSERV');
$ok
}
}
Truth table33%1/3
A || B
A= eval {
do {
require Socket;
'Socket'->VERSION(1.95);
my $ok = Socket::inet_pton(10, '::1') && 10;
$ok and 'Socket'->import('inet_pton', 'getnameinfo', 'NI_NUMERICHOST', 'NI_NUMERICSERV');
$ok
}
}B= eval {
do {
require Socket6;
my $ok = Socket6::inet_pton(10, '::1') && 10;
$ok and 'Socket6'->import('inet_pton', 'getnameinfo', 'NI_NUMERICHOST', 'NI_NUMERICSERV');
$ok
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | require Socket6; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | my $ok = Socket6::inet_pton( AF_INET6(),'::1') && AF_INET6(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
Socket6::inet_pton(10, '::1') && 10
MC/DC0%0/1
Socket6::inet_pton(10, '::1') && 10
Socket6::inet_pton(10, '::1')
Truth table0%0/2
A
A= Socket6::inet_pton(10, '::1')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | $ok && Socket6->import( qw/inet_pton getnameinfo NI_NUMERICHOST NI_NUMERICSERV/ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $ok; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | # try IO::Socket::IP or IO::Socket::INET6 for IPv6 support | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 26 | ▶ | if ( $ip6 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | # if we have IO::Socket::IP >= 0.20 we will use this in preference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | # because it can handle both IPv4 and IPv6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 26 | ▶ | if ( eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 26 | require IO::Socket::IP; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 25 | ▶ | IO::Socket::IP->VERSION(0.20) && IO::Socket::IP->VERSION != 0.30; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 25 | @ISA = qw(IO::Socket::IP); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 25 | constant->import( CAN_IPV6 => "IO::Socket::IP" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 25 | $IOCLASS = "IO::Socket::IP"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | # if we have IO::Socket::INET6 we will use this not IO::Socket::INET | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | # because it can handle both IPv4 and IPv6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | # require at least 2.62 because of several problems before that version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 1 | } elsif( eval { require IO::Socket::INET6; IO::Socket::INET6->VERSION(2.62) } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | @ISA = qw(IO::Socket::INET6); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | constant->import( CAN_IPV6 => "IO::Socket::INET6" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | $IOCLASS = "IO::Socket::INET6"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 1 | $ip6 = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | # fall back to IO::Socket::INET for IPv4 only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 26 | ▶ | if ( ! $ip6 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 1 | @ISA = qw(IO::Socket::INET); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 1 | $IOCLASS = "IO::Socket::INET"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 1 | constant->import( CAN_IPV6 => '' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | #Make $DEBUG another name for $Net::SSLeay::trace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 26 | *DEBUG = \$Net::SSLeay::trace; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | #Compatibility | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 26 | *ERROR = \$SSL_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | sub DEBUG { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | $DEBUG or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DEBUG: not called CC=4 SCAR=30.0
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my (undef,$file,$line) = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | my $msg = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | $file = '...'.substr( $file,-17 ) if length($file)>20; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | $msg = sprintf $msg,@_ if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | print STDERR "DEBUG: $file:$line: $msg\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | # import some constants from Net::SSLeay or use hard-coded defaults | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | # if Net::SSLeay isn't recent enough to provide the constants | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 26 | ▶ | my %const = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | NID_CommonName => 13, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | GEN_DNS => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | GEN_IPADD => 7, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 26 | ▶ | while ( my ($name,$value) = each %const ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 26 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 78 | ▶ | *{$name} = UNIVERSAL::can( 'Net::SSLeay', $name ) || sub { $value }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
Condition33%1/3
UNIVERSAL::can('Net::SSLeay', $name) || sub {
$value;
}
MC/DC0%0/2
UNIVERSAL::can('Net::SSLeay', $name) || sub {
$value;
}
UNIVERSAL::can('Net::SSLeay', $name)
sub {
$value;
}
Truth table33%1/3
A || B
A= UNIVERSAL::can('Net::SSLeay', $name)B= sub {
$value;
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 26 | *idn_to_ascii = \&IO::Socket::SSL::PublicSuffix::idn_to_ascii; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 26 | *idn_to_unicode = \&IO::Socket::SSL::PublicSuffix::idn_to_unicode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 26 | my %default_ca; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | my $ca_detected; # 0: never detect, undef: need to (re)detect | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 26 | my $openssldir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | sub default_ca { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 24 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_ca: called CC=24 SCAR=48.8
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | # user defined default CA or reset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 1 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | %default_ca = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | $ca_detected = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } elsif ( my $path = shift ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 1 | ▶ | %default_ca = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | -d $path ? ( SSL_ca_path => $path ) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | -f $path ? ( SSL_ca_file => $path ) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | die "no such file or directory $path"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 1 | $ca_detected = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | $ca_detected = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 24 | ▶ | return %default_ca if defined $ca_detected; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 17 | ▶ | $openssldir ||= Net::SSLeay::SSLeay_version(5) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition37%3/8
$openssldir ||= &Net::SSLeay::SSLeay_version(5) =~ /^OPENSSLDIR: "(.+)"$/ && $1 || ""
&Net::SSLeay::SSLeay_version(5) =~ /^OPENSSLDIR: "(.+)"$/ && $1 || ''
&Net::SSLeay::SSLeay_version(5) =~ /^OPENSSLDIR: "(.+)"$/ and $1
MC/DC0%0/3
$openssldir ||= &Net::SSLeay::SSLeay_version(5) =~ /^OPENSSLDIR: "(.+)"$/ && $1 || ""
$openssldir
&Net::SSLeay::SSLeay_version(5) =~ /^OPENSSLDIR: "(.+)"$/
$1
Truth table0%0/4
A ||= B and C
A= $openssldirB= &Net::SSLeay::SSLeay_version(5) =~ /^OPENSSLDIR: "(.+)"$/C= $1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | =~m{^OPENSSLDIR: "(.+)"$} && $1 || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | # (re)detect according to openssl crypto/cryptlib.h | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | my $dir = $ENV{SSL_CERT_DIR} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 17 | ▶ | || ( $^O =~m{vms}i ? "SSLCERTS:":"$openssldir/certs" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ENV{'SSL_CERT_DIR'} || ($^O =~ /vms/i ? 'SSLCERTS:' : "$openssldir/certs")
MC/DC0%0/2
$ENV{'SSL_CERT_DIR'} || ($^O =~ /vms/i ? 'SSLCERTS:' : "$openssldir/certs")
$ENV{'SSL_CERT_DIR'}
($^O =~ /vms/i ? 'SSLCERTS:' : "$openssldir/certs")
Truth table33%1/3
A || B
A= $ENV{'SSL_CERT_DIR'}B= ($^O =~ /vms/i ? 'SSLCERTS:' : "$openssldir/certs")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 17 | ▶ | if ( opendir(my $dh,$dir)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | FILES: for my $f ( grep { m{^[a-f\d]{8}(\.\d+)?$} } readdir($dh) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | open( my $fh,'<',"$dir/$f") or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | while (my $line = <$fh>) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | $line =~m{^-+BEGIN (X509 |TRUSTED |)CERTIFICATE-} or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | $default_ca{SSL_ca_path} = $dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | last FILES; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | my $file = $ENV{SSL_CERT_FILE} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 17 | ▶ | || ( $^O =~m{vms}i ? "SSLCERTS:cert.pem":"$openssldir/cert.pem" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ENV{'SSL_CERT_FILE'} || ($^O =~ /vms/i ? 'SSLCERTS:cert.pem' : "$openssldir/cert.pem")
MC/DC0%0/2
$ENV{'SSL_CERT_FILE'} || ($^O =~ /vms/i ? 'SSLCERTS:cert.pem' : "$openssldir/cert.pem")
$ENV{'SSL_CERT_FILE'}
($^O =~ /vms/i ? 'SSLCERTS:cert.pem' : "$openssldir/cert.pem")
Truth table33%1/3
A || B
A= $ENV{'SSL_CERT_FILE'}B= ($^O =~ /vms/i ? 'SSLCERTS:cert.pem' : "$openssldir/cert.pem")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 17 | ▶ | if ( open(my $fh,'<',$file)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | while (my $line = <$fh>) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | $line =~m{^-+BEGIN (X509 |TRUSTED |)CERTIFICATE-} or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | $default_ca{SSL_ca_file} = $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | $default_ca{SSL_ca_file} = Mozilla::CA::SSL_ca_file() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 17 | ▶ | if ! %default_ca && eval { require Mozilla::CA }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not %default_ca and eval {
do {
require Mozilla::CA
}
}
MC/DC0%0/2
not %default_ca and eval {
do {
require Mozilla::CA
}
}
not %default_ca
eval {
do {
require Mozilla::CA
}
}
Truth table33%1/3
not(A) and B
A= not %default_caB= eval {
do {
require Mozilla::CA
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 17 | $ca_detected = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 17 | return %default_ca; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | # Export some stuff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | # inet4|inet6|debug will be handled by myself, everything | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | # else will be handled the Exporter way | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 26 | sub import { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 51 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=7 SCAR=27.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 51 | my @export; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 51 | foreach (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 1 | ▶ | if ( /^inet4$/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | # explicitly fall back to inet4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | @ISA = 'IO::Socket::INET'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | @caller_force_inet4 = caller(); # save for warnings for 'inet6' case | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } elsif ( /^inet6$/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | # check if we have already ipv6 as base | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | if ( ! UNIVERSAL::isa( $class, 'IO::Socket::INET6') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
UNIVERSAL::isa($class, "IO::Socket::INET6") or UNIVERSAL::isa($class, "IO::Socket::IP")
MC/DC0%0/2
UNIVERSAL::isa($class, "IO::Socket::INET6") or UNIVERSAL::isa($class, "IO::Socket::IP")
UNIVERSAL::isa($class, "IO::Socket::INET6")
UNIVERSAL::isa($class, "IO::Socket::IP")
Truth table0%0/3
A or B
A= UNIVERSAL::isa($class, "IO::Socket::INET6")B= UNIVERSAL::isa($class, "IO::Socket::IP")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | and ! UNIVERSAL::isa( $class, 'IO::Socket::IP' )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | # either we don't support it or we disabled it by explicitly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | # loading it with 'inet4'. In this case re-enable but warn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | # because this is probably an error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | if ( CAN_IPV6 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | @ISA = ( CAN_IPV6 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | warn "IPv6 support re-enabled in __PACKAGE__, got disabled in file $caller_force_inet4[1] line $caller_force_inet4[2]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | die "INET6 is not supported, install IO::Socket::INET6"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | } elsif ( /^:?debug(\d+)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 1 | $DEBUG=$1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 2 | push @export,$_ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 51 | @_ = ( $class,@export ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 49 | goto &Exporter::import; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 26 | my %SSL_OBJECT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | my %CREATED_IN_THIS_THREAD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | sub CLONE { %CREATED_IN_THIS_THREAD = (); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CLONE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | # You might be expecting to find a new() subroutine here, but that is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | # not how IO::Socket::INET works. All configuration gets performed in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | # the calls to configure() and either connect() or accept(). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | #Call to configure occurs when a new socket is made using | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | #IO::Socket::INET. Returns false (empty list) on failure. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | sub configure { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 17 | ▶ | my ($self, $arg_hash) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
configure: called CC=7 SCAR=20.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 17 | ▶ | return _invalid_object() unless($self); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | # force initial blocking | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | # otherwise IO::Socket::SSL->new might return undef if the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | # socket is nonblocking and it fails to connect immediately | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | # for real nonblocking behavior one should create a nonblocking | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | # socket and later call connect explicitly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 17 | my $blocking = delete $arg_hash->{Blocking}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | # because Net::HTTPS simple redefines blocking() to {} (e.g | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | # return undef) and IO::Socket::INET does not like this we | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | # set Blocking only explicitly if it was set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 17 | ▶ | $arg_hash->{Blocking} = 1 if defined ($blocking); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 17 | ▶ | $self->configure_SSL($arg_hash) || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 6 | ▶ | $self->SUPER::configure($arg_hash) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | || return $self->_internal_error("@ISA configuration failed"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 4 | ▶ | $self->blocking(0) if defined $blocking && !$blocking; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $blocking and not $blocking
MC/DC0%0/2
defined $blocking and not $blocking
defined $blocking
not $blocking
Truth table33%1/3
A and not(B)
A= defined $blockingB= not $blocking
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 4 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | sub configure_SSL { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 30 | ▶ | my ($self, $arg_hash) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
configure_SSL: called CC=16 SCAR=32.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 30 | ▶ | $arg_hash->{Proto} ||= 'tcp'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$arg_hash->{"Proto"} ||= "tcp"
MC/DC0%0/1
$arg_hash->{"Proto"} ||= "tcp"
$arg_hash->{"Proto"}
Truth table50%1/2
A
A= $arg_hash->{"Proto"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 30 | my $is_server = $arg_hash->{SSL_server}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 30 | ▶ | if ( ! defined $is_server ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 17 | ▶ | $is_server = $arg_hash->{SSL_server} = $arg_hash->{Listen} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$arg_hash->{'Listen'} || 0
MC/DC100%1/1
$arg_hash->{'Listen'} || 0
$arg_hash->{'Listen'}
Truth table100%2/2
A
A= $arg_hash->{'Listen'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | # add user defined defaults, maybe after filtering | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 30 | ▶ | $FILTER_SSL_ARGS->($is_server,$arg_hash) if $FILTER_SSL_ARGS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 30 | ▶ | my %defaults = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | %$GLOBAL_SSL_ARGS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | $is_server ? %$GLOBAL_SSL_SERVER_ARGS : %$GLOBAL_SSL_CLIENT_ARGS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 30 | ▶ | if ( $defaults{SSL_reuse_ctx} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | # ignore default context if there are args to override it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | delete $defaults{SSL_reuse_ctx} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | ▶ | if grep { m{^SSL_(?!verifycn_name|hostname)$} } keys %$arg_hash; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 30 | ▶ | %$arg_hash = ( %defaults, %$arg_hash ) if %defaults; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 30 | my $ctx = $arg_hash->{'SSL_reuse_ctx'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 30 | ▶ | if ($ctx) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | ▶ | if ($ctx->isa('IO::Socket::SSL::SSL_Context') and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$ctx->isa("IO::Socket::SSL::SSL_Context") and $ctx->{"context"}
MC/DC0%0/2
$ctx->isa("IO::Socket::SSL::SSL_Context") and $ctx->{"context"}
$ctx->isa("IO::Socket::SSL::SSL_Context")
$ctx->{"context"}
Truth table0%0/3
A and B
A= $ctx->isa("IO::Socket::SSL::SSL_Context")B= $ctx->{"context"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | $ctx->{context}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | # valid context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | } elsif ( $ctx = ${*$ctx}{_SSL_ctx} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | # reuse context from existing SSL object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | # create context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | # this will fill in defaults in $arg_hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 30 | ▶ | $ctx ||= IO::Socket::SSL::SSL_Context->new($arg_hash) || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition80%4/5
$ctx ||= "IO::Socket::SSL::SSL_Context"->new($arg_hash) || (return)
'IO::Socket::SSL::SSL_Context'->new($arg_hash) || (return)
MC/DC50%1/2
$ctx ||= "IO::Socket::SSL::SSL_Context"->new($arg_hash) || (return)
$ctx
'IO::Socket::SSL::SSL_Context'->new($arg_hash)
Truth table66%2/3
A ||= B
A= $ctxB= 'IO::Socket::SSL::SSL_Context'->new($arg_hash)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 14 | ${*$self}{'_SSL_arguments'} = $arg_hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 14 | ${*$self}{'_SSL_ctx'} = $ctx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 14 | ▶ | ${*$self}{'_SSL_opened'} = 1 if $is_server; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 14 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | sub _skip_rw_error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 23 | ▶ | my ($self,$ssl,$rv) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_skip_rw_error: called CC=5 SCAR=16.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 23 | my $err = Net::SSLeay::get_error($ssl,$rv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 23 | ▶ | if ( $err == Net::SSLeay::ERROR_WANT_READ()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 9 | $SSL_ERROR = SSL_WANT_READ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } elsif ( $err == Net::SSLeay::ERROR_WANT_WRITE()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | $SSL_ERROR = SSL_WANT_WRITE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 14 | return $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 9 | ▶ | $! ||= EAGAIN; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$! ||= 11
MC/DC0%0/1
$! ||= 11
$!
Truth table50%1/2
A
A= $!
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 9 | ▶ | ${*$self}{'_SSL_last_err'} = $SSL_ERROR if ref($self); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 9 | Net::SSLeay::ERR_clear_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 9 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | # Call to connect occurs when a new client socket is made using IO::Socket::* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | sub connect { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 2 | ▶ | my $self = shift || return _invalid_object(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
connect: called CC=9 SCAR=24.1
Pod
documented
Condition50%1/2
shift() || (return _invalid_object())
MC/DC0%0/1
shift() || (return _invalid_object())
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 2 | ▶ | return $self if ${*$self}{'_SSL_opened'}; # already connected | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 2 | ▶ | if ( ! ${*$self}{'_SSL_opening'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | # call SUPER::connect if the underlying socket is not connected | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | # if this fails this might not be an error (e.g. if $! = EINPROGRESS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | # and socket is nonblocking this is normal), so keep any error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | # handling to the client | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 2 | ▶ | $DEBUG>=2 && DEBUG('socket not yet connected' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 2 | ▶ | $self->SUPER::connect(@_) || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 2 | ▶ | $DEBUG>=2 && DEBUG('socket connected' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | # IO::Socket works around systems, which return EISCONN or similar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | # on non-blocking re-connect by returning true, even if $! is set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | # but it does not clear $!, so do it here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 2 | $! = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | # don't continue with connect_SSL if SSL_startHandshake is set to 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 2 | my $sh = ${*$self}{_SSL_arguments}{SSL_startHandshake}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 2 | ▶ | return $self if defined $sh && ! $sh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $sh and not $sh
MC/DC0%0/2
defined $sh and not $sh
defined $sh
not $sh
Truth table33%1/3
A and not(B)
A= defined $shB= not $sh
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 2 | return $self->connect_SSL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | sub connect_SSL { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 10 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
connect_SSL: called CC=77 SCAR=67.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 10 | ▶ | my $args = @_>1 ? {@_}: $_[0]||{}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$_[0] or {}
MC/DC0%0/1
$_[0] or {}
$_[0]
Truth table50%1/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 10 | my ($ssl,$ctx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 10 | ▶ | if ( ! ${*$self}{'_SSL_opening'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | # start ssl connection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 10 | ▶ | $DEBUG>=2 && DEBUG('ssl handshake not started' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 10 | ${*$self}{'_SSL_opening'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 10 | my $arg_hash = ${*$self}{'_SSL_arguments'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 10 | my $fileno = ${*$self}{'_SSL_fileno'} = fileno($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 10 | ▶ | return $self->_internal_error("Socket has no fileno") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | if ! defined $fileno; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 10 | $ctx = ${*$self}{'_SSL_ctx'}; # Reference to real context | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 10 | $ssl = ${*$self}{'_SSL_object'} = Net::SSLeay::new($ctx->{context}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 10 | ▶ | || return $self->error("SSL structure creation failed"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
&Net::SSLeay::new($ctx->{'context'}) || (return $self->error('SSL structure creation failed'))
MC/DC0%0/1
&Net::SSLeay::new($ctx->{'context'}) || (return $self->error('SSL structure creation failed'))
&Net::SSLeay::new($ctx->{'context'})
Truth table50%1/2
A
A= &Net::SSLeay::new($ctx->{'context'})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 10 | $CREATED_IN_THIS_THREAD{$ssl} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 10 | $SSL_OBJECT{$ssl} = [$self,0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 10 | weaken($SSL_OBJECT{$ssl}[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 10 | ▶ | Net::SSLeay::set_fd($ssl, $fileno) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | || return $self->error("SSL filehandle association failed"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 10 | ▶ | if ( $can_client_sni ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 10 | my $host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 10 | ▶ | if ( exists $arg_hash->{SSL_hostname} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | # explicitly given | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | # can be set to undef/'' to not use extension | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | $host = $arg_hash->{SSL_hostname} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | ▶ | } elsif ( $host = $arg_hash->{PeerAddr} || $arg_hash->{PeerHost} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$arg_hash->{'PeerAddr'} || $arg_hash->{'PeerHost'}
MC/DC50%1/2
$arg_hash->{'PeerAddr'} || $arg_hash->{'PeerHost'}
$arg_hash->{'PeerAddr'}
$arg_hash->{'PeerHost'}
Truth table66%2/3
A || B
A= $arg_hash->{'PeerAddr'}B= $arg_hash->{'PeerHost'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | # implicitly given | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 2 | $host =~s{:[a-zA-Z0-9_\-]+$}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | # should be hostname, not IPv4/6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 2 | ▶ | $host = undef if $host !~m{[a-z_]} or $host =~m{:}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $host =~ /[a-z_]/ or $host =~ /:/
MC/DC0%0/2
not $host =~ /[a-z_]/ or $host =~ /:/
not $host =~ /[a-z_]/
$host =~ /:/
Truth table33%1/3
not(A) or B
A= not $host =~ /[a-z_]/B= $host =~ /:/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | # define SSL_CTRL_SET_TLSEXT_HOSTNAME 55 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | # define TLSEXT_NAMETYPE_host_name 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 10 | ▶ | if ($host) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | ▶ | $DEBUG>=2 && DEBUG("using SNI with hostname $host"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | Net::SSLeay::ctrl($ssl,55,0,$host); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 10 | ▶ | $DEBUG>=2 && DEBUG("not using SNI because hostname is unknown"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | } elsif ( $arg_hash->{SSL_hostname} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | return $self->_internal_error( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | "Client side SNI not supported for this openssl"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | ▶ | $DEBUG>=2 && DEBUG("not using SNI because openssl is too old"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 10 | ▶ | $arg_hash->{PeerAddr} || $arg_hash->{PeerHost} || $self->_update_peer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$arg_hash->{"PeerAddr"} or $arg_hash->{"PeerHost"}
MC/DC50%1/2
$arg_hash->{"PeerAddr"} or $arg_hash->{"PeerHost"}
$arg_hash->{"PeerAddr"}
$arg_hash->{"PeerHost"}
Truth table66%2/3
A or B
A= $arg_hash->{"PeerAddr"}B= $arg_hash->{"PeerHost"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 10 | ▶ | if ( $ctx->{verify_name_ref} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | # need target name for update | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | my $host = $arg_hash->{SSL_verifycn_name} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | ▶ | || $arg_hash->{SSL_hostname}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$arg_hash->{'SSL_verifycn_name'} || $arg_hash->{'SSL_hostname'}
MC/DC0%0/2
$arg_hash->{'SSL_verifycn_name'} || $arg_hash->{'SSL_hostname'}
$arg_hash->{'SSL_verifycn_name'}
$arg_hash->{'SSL_hostname'}
Truth table0%0/3
A || B
A= $arg_hash->{'SSL_verifycn_name'}B= $arg_hash->{'SSL_hostname'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | ▶ | if ( ! defined $host ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | ▶ | if ( $host = $arg_hash->{PeerAddr} || $arg_hash->{PeerHost} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$arg_hash->{'PeerAddr'} || $arg_hash->{'PeerHost'}
MC/DC0%0/2
$arg_hash->{'PeerAddr'} || $arg_hash->{'PeerHost'}
$arg_hash->{'PeerAddr'}
$arg_hash->{'PeerHost'}
Truth table0%0/3
A || B
A= $arg_hash->{'PeerAddr'}B= $arg_hash->{'PeerHost'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | $host =~s{:[a-zA-Z0-9_\-]+$}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | ${$ctx->{verify_name_ref}} = $host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 10 | my $ocsp = $ctx->{ocsp_mode}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 10 | ▶ | if ( $ocsp & SSL_OCSP_NO_STAPLE ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | # don't try stapling | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | } elsif ( ! $can_ocsp_staple ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | croak("OCSP stapling not support") if $ocsp & SSL_OCSP_MUST_STAPLE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | } elsif ( $ocsp & (SSL_OCSP_TRY_STAPLE|SSL_OCSP_MUST_STAPLE)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | # staple by default if verification enabled | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | ${*$self}{_SSL_ocsp_verify} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | Net::SSLeay::set_tlsext_status_type($ssl, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | Net::SSLeay::TLSEXT_STATUSTYPE_ocsp()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | ▶ | $DEBUG>=2 && DEBUG("request OCSP stapling"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | my $session = $ctx->session_cache( $arg_hash->{SSL_session_key} ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | ( $arg_hash->{SSL_session_key},1 ) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | $arg_hash->{PeerAddr} || $arg_hash->{PeerHost}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | $arg_hash->{PeerPort} || $arg_hash->{PeerService} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 10 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$arg_hash->{"PeerAddr"} or $arg_hash->{"PeerHost"}
$arg_hash->{"PeerPort"} or $arg_hash->{"PeerService"}
MC/DC0%0/2
$arg_hash->{"PeerAddr"} or $arg_hash->{"PeerHost"}
$arg_hash->{"PeerAddr"}
$arg_hash->{"PeerHost"}
MC/DC0%0/2
$arg_hash->{"PeerPort"} or $arg_hash->{"PeerService"}
$arg_hash->{"PeerPort"}
$arg_hash->{"PeerService"}
Truth table66%2/3
A or B
A= $arg_hash->{"PeerAddr"}B= $arg_hash->{"PeerHost"}
Truth table66%2/3
A or B
A= $arg_hash->{"PeerPort"}B= $arg_hash->{"PeerService"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 10 | ▶ | Net::SSLeay::set_session($ssl, $session) if ($session); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 10 | ▶ | $ssl ||= ${*$self}{'_SSL_object'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$ssl ||= do {
*$self
}->{"_SSL_object"}
MC/DC0%0/2
$ssl ||= do {
*$self
}->{"_SSL_object"}
$ssl
do {
*$self
}->{"_SSL_object"}
Truth table33%1/3
A ||= B
A= $sslB= do {
*$self
}->{"_SSL_object"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 10 | $SSL_ERROR = $! = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | my $timeout = exists $args->{Timeout} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | ? $args->{Timeout} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 10 | ▶ | : ${*$self}{io_socket_timeout}; # from IO::Socket | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 10 | ▶ | if ( defined($timeout) && $timeout>0 && $self->blocking(0) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
defined $timeout and $timeout > 0 and $self->blocking(0)
defined $timeout and $timeout > 0
MC/DC33%1/3
defined $timeout and $timeout > 0 and $self->blocking(0)
defined $timeout
$timeout > 0
$self->blocking(0)
Truth table50%2/4
A and B and C
A= defined $timeoutB= $timeout > 0C= $self->blocking(0)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 4 | ▶ | $DEBUG>=2 && DEBUG( "set socket to non-blocking to enforce timeout=$timeout" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | # timeout was given and socket was blocking | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | # enforce timeout with now non-blocking socket | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | # timeout does not apply because invalid or socket non-blocking | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 6 | $timeout = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 10 | ▶ | my $start = defined($timeout) && time(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $timeout && time
MC/DC50%1/2
defined $timeout && time
defined $timeout
time
Truth table66%2/3
A && B
A= defined $timeoutB= time
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 10 | for my $dummy (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | #DEBUG( 'calling ssleay::connect' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 17 | my $rv = Net::SSLeay::connect($ssl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 17 | ▶ | $DEBUG>=3 && DEBUG("Net::SSLeay::connect -> $rv" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 17 | ▶ | if ( $rv < 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 13 | ▶ | if ( my $err = $self->_skip_rw_error( $ssl,$rv )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 4 | $self->error("SSL connect attempt failed"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 4 | delete ${*$self}{'_SSL_opening'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 4 | ${*$self}{'_SSL_opened'} = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 4 | ▶ | $DEBUG>=1 && DEBUG( "fatal SSL error: $SSL_ERROR" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 4 | return $self->fatal_ssl_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 9 | ▶ | $DEBUG>=2 && DEBUG('ssl handshake in progress' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | # connect failed because handshake needs to be completed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | # if socket was non-blocking or no timeout was given return with this error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 9 | ▶ | return if ! defined($timeout); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | # wait until socket is readable or writable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 7 | my $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 7 | ▶ | if ( $timeout>0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 7 | my $vec = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 7 | vec($vec,$self->fileno,1) = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 7 | ▶ | $DEBUG>=2 && DEBUG( "waiting for fd to become ready: $SSL_ERROR" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 7 | ▶ | $rv = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | $SSL_ERROR == SSL_WANT_READ ? select( $vec,undef,undef,$timeout) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | $SSL_ERROR == SSL_WANT_WRITE ? select( undef,$vec,undef,$timeout) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | ▶ | $DEBUG>=2 && DEBUG("handshake failed because no more time" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | $! = ETIMEDOUT | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 7 | ▶ | if ( ! $rv ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | ▶ | $DEBUG>=2 && DEBUG("handshake failed because socket did not became ready" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | # failed because of timeout, return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | ▶ | $! ||= ETIMEDOUT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$! ||= 110
MC/DC0%0/1
$! ||= 110
$!
Truth table0%0/2
A
A= $!
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | delete ${*$self}{'_SSL_opening'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | ${*$self}{'_SSL_opened'} = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | $self->blocking(1); # was blocking before | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | # socket is ready, try non-blocking connect again after recomputing timeout | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 7 | ▶ | $DEBUG>=2 && DEBUG("socket ready, retrying connect" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 7 | my $now = time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 7 | $timeout -= $now - $start; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 7 | $start = $now; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 7 | redo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | } elsif ( $rv == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | delete ${*$self}{'_SSL_opening'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | ▶ | $DEBUG>=2 && DEBUG("connection failed - connect returned 0" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | $self->error("SSL connect attempt failed because of handshake problems" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | ${*$self}{'_SSL_opened'} = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | return $self->fatal_ssl_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 4 | ▶ | $DEBUG>=2 && DEBUG('ssl handshake done' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | # ssl connect successful | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 4 | delete ${*$self}{'_SSL_opening'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 4 | ${*$self}{'_SSL_opened'}=1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 4 | ▶ | $self->blocking(1) if defined($timeout); # was blocking before | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 4 | ▶ | $ctx ||= ${*$self}{'_SSL_ctx'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$ctx ||= do {
*$self
}->{"_SSL_ctx"}
MC/DC0%0/2
$ctx ||= do {
*$self
}->{"_SSL_ctx"}
$ctx
do {
*$self
}->{"_SSL_ctx"}
Truth table33%1/3
A ||= B
A= $ctxB= do {
*$self
}->{"_SSL_ctx"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 4 | ▶ | if ( my $ocsp_result = ${*$self}{_SSL_ocsp_verify} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | # got result from OCSP stapling | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | ▶ | if ( $ocsp_result->[0] > 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | ▶ | $DEBUG>=3 && DEBUG("got OCSP success with stapling"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | # successful validated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | } elsif ( $ocsp_result->[0] < 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | # Permanent problem with validation because certificate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | # is either self-signed or the issuer cannot be found. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | # Ignore here, because this will cause other errors too. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | ▶ | $DEBUG>=3 && DEBUG("got OCSP failure with stapling: %s", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | $ocsp_result->[1]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | # definitly revoked | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | ▶ | $DEBUG>=3 && DEBUG("got OCSP revocation with stapling: %s", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | $ocsp_result->[1]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | $self->_internal_error($ocsp_result->[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | return $self->fatal_ssl_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | } elsif ( $ctx->{ocsp_mode} & SSL_OCSP_MUST_STAPLE ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | $self->_internal_error("did not receive the required stapled OCSP response"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | return $self->fatal_ssl_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 4 | ▶ | if ( $ctx->has_session_cache | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ctx->has_session_cache and my $session = &Net::SSLeay::get1_session($ssl)
MC/DC0%0/2
$ctx->has_session_cache and my $session = &Net::SSLeay::get1_session($ssl)
$ctx->has_session_cache
my $session = &Net::SSLeay::get1_session($ssl)
Truth table33%1/3
A and B
A= $ctx->has_session_cacheB= my $session = &Net::SSLeay::get1_session($ssl)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | and my $session = Net::SSLeay::get1_session($ssl)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | my $arg_hash = ${*$self}{'_SSL_arguments'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | ▶ | $arg_hash->{PeerAddr} || $arg_hash->{PeerHost} || $self->_update_peer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$arg_hash->{"PeerAddr"} or $arg_hash->{"PeerHost"}
MC/DC0%0/2
$arg_hash->{"PeerAddr"} or $arg_hash->{"PeerHost"}
$arg_hash->{"PeerAddr"}
$arg_hash->{"PeerHost"}
Truth table0%0/3
A or B
A= $arg_hash->{"PeerAddr"}B= $arg_hash->{"PeerHost"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | $ctx->session_cache( $arg_hash->{SSL_session_key} ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | ( $arg_hash->{SSL_session_key},1 ) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | $arg_hash->{PeerAddr} || $arg_hash->{PeerHost}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | $arg_hash->{PeerPort} || $arg_hash->{PeerService} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | ▶ | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$arg_hash->{"PeerAddr"} or $arg_hash->{"PeerHost"}
$arg_hash->{"PeerPort"} or $arg_hash->{"PeerService"}
MC/DC0%0/2
$arg_hash->{"PeerAddr"} or $arg_hash->{"PeerHost"}
$arg_hash->{"PeerAddr"}
$arg_hash->{"PeerHost"}
MC/DC0%0/2
$arg_hash->{"PeerPort"} or $arg_hash->{"PeerService"}
$arg_hash->{"PeerPort"}
$arg_hash->{"PeerService"}
Truth table0%0/3
A or B
A= $arg_hash->{"PeerAddr"}B= $arg_hash->{"PeerHost"}
Truth table0%0/3
A or B
A= $arg_hash->{"PeerPort"}B= $arg_hash->{"PeerService"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | $session | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 4 | tie *{$self}, "IO::Socket::SSL::SSL_HANDLE", $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 4 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | # called if PeerAddr is not set in ${*$self}{'_SSL_arguments'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | # this can be the case if start_SSL is called with a normal IO::Socket::INET | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | # so that PeerAddr|PeerPort are not set from args | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | sub _update_peer { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 8 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_update_peer: called CC=2 SCAR=7.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 8 | my $arg_hash = ${*$self}{'_SSL_arguments'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 8 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 8 | my $sockaddr = getpeername( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 8 | my $af = sockaddr_family($sockaddr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 8 | ▶ | if( CAN_IPV6 && $af == AF_INET6 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | my ($host, $port) = getnameinfo($sockaddr, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | NI_NUMERICHOST | NI_NUMERICSERV); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | $arg_hash->{PeerAddr} = $host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | $arg_hash->{PeerPort} = $port; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 8 | my ($port,$addr) = sockaddr_in( $sockaddr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 8 | $arg_hash->{PeerAddr} = inet_ntoa( $addr ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 8 | $arg_hash->{PeerPort} = $port; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | #Call to accept occurs when a new client connects to a server using | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | #IO::Socket::SSL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | sub accept { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 3 | ▶ | my $self = shift || return _invalid_object(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
accept: called CC=14 SCAR=39.6
Pod
documented
Condition50%1/2
shift() || (return _invalid_object())
MC/DC0%0/1
shift() || (return _invalid_object())
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 3 | ▶ | my $class = shift || 'IO::Socket::SSL'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || 'IO::Socket::SSL'
MC/DC0%0/1
shift() || 'IO::Socket::SSL'
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 3 | my $socket = ${*$self}{'_SSL_opening'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 3 | ▶ | if ( ! $socket ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | # underlying socket not done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 3 | ▶ | $DEBUG>=2 && DEBUG('no socket yet' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 3 | ▶ | $socket = $self->SUPER::accept($class) || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->SUPER::accept($class) || (return)
MC/DC0%0/1
$self->SUPER::accept($class) || (return)
$self->SUPER::accept($class)
Truth table50%1/2
A
A= $self->SUPER::accept($class)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 3 | ▶ | $DEBUG>=2 && DEBUG('accept created normal socket '.$socket ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | # don't continue with accept_SSL if SSL_startHandshake is set to 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 3 | my $sh = ${*$self}{_SSL_arguments}{SSL_startHandshake}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 3 | ▶ | if (defined $sh && ! $sh) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $sh and not $sh
MC/DC0%0/2
defined $sh and not $sh
defined $sh
not $sh
Truth table33%1/3
A and not(B)
A= defined $shB= not $sh
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | ${*$socket}{_SSL_ctx} = ${*$self}{_SSL_ctx}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 0 | ${*$socket}{_SSL_arguments} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | %{${*$self}{_SSL_arguments}}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | SSL_server => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | ▶ | $DEBUG>=2 && DEBUG('will not start SSL handshake yet'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | ▶ | return wantarray ? ($socket, getpeername($socket) ) : $socket | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 3 | ▶ | $self->accept_SSL($socket) || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | ▶ | $DEBUG>=2 && DEBUG('accept_SSL ok' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | ▶ | return wantarray ? ($socket, getpeername($socket) ) : $socket; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | sub accept_SSL { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
accept_SSL: called CC=30 SCAR=51.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 3 | ▶ | my $socket = ( @_ && UNIVERSAL::isa( $_[0], 'IO::Handle' )) ? shift : $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ and UNIVERSAL::isa($_[0], "IO::Handle")
MC/DC0%0/2
@_ and UNIVERSAL::isa($_[0], "IO::Handle")
@_
UNIVERSAL::isa($_[0], "IO::Handle")
Truth table33%1/3
A and B
A= @_B= UNIVERSAL::isa($_[0], "IO::Handle")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 3 | ▶ | my $args = @_>1 ? {@_}: $_[0]||{}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$_[0] or {}
MC/DC0%0/1
$_[0] or {}
$_[0]
Truth table50%1/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 3 | my $ssl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 3 | ▶ | if ( ! ${*$self}{'_SSL_opening'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 3 | ▶ | $DEBUG>=2 && DEBUG('starting sslifying' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 3 | ${*$self}{'_SSL_opening'} = $socket; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 3 | ▶ | if ($socket != $self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 3 | ${*$socket}{_SSL_ctx} = ${*$self}{_SSL_ctx}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 3 | ${*$socket}{_SSL_arguments} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 3 | %{${*$self}{_SSL_arguments}}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | SSL_server => 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 3 | my $fileno = ${*$socket}{'_SSL_fileno'} = fileno($socket); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 3 | ▶ | return $socket->_internal_error("Socket has no fileno") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | if ! defined $fileno; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 3 | $ssl = ${*$socket}{_SSL_object} = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 3 | Net::SSLeay::new(${*$socket}{_SSL_ctx}{context}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 3 | ▶ | || return $socket->error("SSL structure creation failed"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
&Net::SSLeay::new(do {
*$socket
}->{'_SSL_ctx'}{'context'}) || (return $socket->error('SSL structure creation failed'))
MC/DC0%0/1
&Net::SSLeay::new(do {
*$socket
}->{'_SSL_ctx'}{'context'}) || (return $socket->error('SSL structure creation failed'))
&Net::SSLeay::new(do {
*$socket
}->{'_SSL_ctx'}{'context'})
Truth table50%1/2
A
A= &Net::SSLeay::new(do {
*$socket
}->{'_SSL_ctx'}{'context'})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 3 | $CREATED_IN_THIS_THREAD{$ssl} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 3 | $SSL_OBJECT{$ssl} = [$socket,1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 3 | weaken($SSL_OBJECT{$ssl}[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 3 | ▶ | Net::SSLeay::set_fd($ssl, $fileno) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | || return $socket->error("SSL filehandle association failed"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 3 | ▶ | $ssl ||= ${*$socket}{'_SSL_object'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$ssl ||= do {
*$socket
}->{"_SSL_object"}
MC/DC0%0/2
$ssl ||= do {
*$socket
}->{"_SSL_object"}
$ssl
do {
*$socket
}->{"_SSL_object"}
Truth table33%1/3
A ||= B
A= $sslB= do {
*$socket
}->{"_SSL_object"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 3 | $SSL_ERROR = $! = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | #$DEBUG>=2 && DEBUG('calling ssleay::accept' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | my $timeout = exists $args->{Timeout} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | ? $args->{Timeout} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 3 | ▶ | : ${*$self}{io_socket_timeout}; # from IO::Socket | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 3 | ▶ | if ( defined($timeout) && $timeout>0 && $socket->blocking(0) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $timeout and $timeout > 0 and $socket->blocking(0)
defined $timeout and $timeout > 0
MC/DC0%0/3
defined $timeout and $timeout > 0 and $socket->blocking(0)
defined $timeout
$timeout > 0
$socket->blocking(0)
Truth table25%1/4
A and B and C
A= defined $timeoutB= $timeout > 0C= $socket->blocking(0)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | # timeout was given and socket was blocking | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | # enforce timeout with now non-blocking socket | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | # timeout does not apply because invalid or socket non-blocking | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 3 | $timeout = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 3 | ▶ | my $start = defined($timeout) && time(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
defined $timeout && time
MC/DC0%0/2
defined $timeout && time
defined $timeout
time
Truth table33%1/3
A && B
A= defined $timeoutB= time
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 3 | for my $dummy (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 3 | my $rv = Net::SSLeay::accept($ssl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 3 | ▶ | $DEBUG>=3 && DEBUG( "Net::SSLeay::accept -> $rv" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 3 | ▶ | if ( $rv < 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 3 | ▶ | if ( my $err = $socket->_skip_rw_error( $ssl,$rv )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 3 | $socket->error("SSL accept attempt failed"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 3 | delete ${*$self}{'_SSL_opening'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 3 | ${*$socket}{'_SSL_opened'} = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 3 | return $socket->fatal_ssl_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | # accept failed because handshake needs to be completed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | # if socket was non-blocking or no timeout was given return with this error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | ▶ | return if ! defined($timeout); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | # wait until socket is readable or writable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | my $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | ▶ | if ( $timeout>0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | my $vec = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | vec($vec,$socket->fileno,1) = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | ▶ | $rv = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | $SSL_ERROR == SSL_WANT_READ ? select( $vec,undef,undef,$timeout) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | $SSL_ERROR == SSL_WANT_WRITE ? select( undef,$vec,undef,$timeout) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | $! = ETIMEDOUT | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | ▶ | if ( ! $rv ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | # failed because of timeout, return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | ▶ | $! ||= ETIMEDOUT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$! ||= 110
MC/DC0%0/1
$! ||= 110
$!
Truth table0%0/2
A
A= $!
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | delete ${*$self}{'_SSL_opening'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | ${*$socket}{'_SSL_opened'} = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | $socket->blocking(1); # was blocking before | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | # socket is ready, try non-blocking accept again after recomputing timeout | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | my $now = time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | $timeout -= $now - $start; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | $start = $now; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | redo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | } elsif ( $rv == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | $socket->error("SSL connect accept failed because of handshake problems" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 0 | delete ${*$self}{'_SSL_opening'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | ${*$socket}{'_SSL_opened'} = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 0 | return $socket->fatal_ssl_error(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 0 | ▶ | $DEBUG>=2 && DEBUG('handshake done, socket ready' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | # socket opened | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | delete ${*$self}{'_SSL_opening'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 0 | ${*$socket}{'_SSL_opened'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 0 | ▶ | $socket->blocking(1) if defined($timeout); # was blocking before | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | tie *{$socket}, "IO::Socket::SSL::SSL_HANDLE", $socket; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | return $socket; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | ####### I/O subroutines ######################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | sub _generic_read { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 0 | ▶ | my ($self, $read_func, undef, $length, $offset) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generic_read: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | ▶ | my $ssl = $self->_get_ssl_object || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->_get_ssl_object || (return)
MC/DC0%0/1
$self->_get_ssl_object || (return)
$self->_get_ssl_object
Truth table0%0/2
A
A= $self->_get_ssl_object
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 0 | my $buffer=\$_[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | $SSL_ERROR = $! = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 0 | my ($data,$rwerr) = $read_func->($ssl, $length); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | ▶ | if ( !defined($data)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 0 | ▶ | if ( my $err = $self->_skip_rw_error( $ssl, defined($rwerr) ? $rwerr:-1 )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 0 | $self->error("SSL read error"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | $length = length($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 0 | ▶ | $$buffer = '' if !defined $$buffer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | ▶ | $offset ||= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$offset ||= 0
MC/DC0%0/1
$offset ||= 0
$offset
Truth table0%0/2
A
A= $offset
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | ▶ | if ($offset>length($$buffer)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | $$buffer.="\0" x ($offset-length($$buffer)); #mimic behavior of read | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | substr($$buffer, $offset, length($$buffer), $data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | return $length; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | sub read { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | ▶ | ${*$self}{_SSL_object} && return _generic_read($self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | $self->blocking ? \&Net::SSLeay::ssl_read_all : \&Net::SSLeay::read, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | @_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | # fall back to plain read if we are not required to use SSL yet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 0 | return $self->SUPER::read(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | # contrary to the behavior of read sysread can read partial data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | sub sysread { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sysread: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 0 | ▶ | ${*$self}{_SSL_object} && return _generic_read( $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | \&Net::SSLeay::read, @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | # fall back to plain sysread if we are not required to use SSL yet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 0 | my $rv = $self->SUPER::sysread(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | return $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | sub peek { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
peek: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | ▶ | ${*$self}{_SSL_object} && return _generic_read( $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | \&Net::SSLeay::peek, @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | # fall back to plain peek if we are not required to use SSL yet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | # emulate peek with recv(...,MS_PEEK) - peek(buf,len,offset) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 0 | ▶ | return if ! defined recv($self,my $buf,$_[1],MSG_PEEK); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | ▶ | $_[0] = $_[2] ? substr($_[0],0,$_[2]).$buf : $buf; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | return length($buf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | sub _generic_write { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 0 | ▶ | my ($self, $write_all, undef, $length, $offset) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generic_write: not called CC=13 SCAR=52.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 0 | ▶ | my $ssl = $self->_get_ssl_object || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->_get_ssl_object || (return)
MC/DC0%0/1
$self->_get_ssl_object || (return)
$self->_get_ssl_object
Truth table0%0/2
A
A= $self->_get_ssl_object
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 0 | my $buffer = \$_[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 0 | my $buf_len = length($$buffer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | ▶ | $length ||= $buf_len; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$length ||= $buf_len
MC/DC0%0/2
$length ||= $buf_len
$length
$buf_len
Truth table0%0/3
A ||= B
A= $lengthB= $buf_len
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | ▶ | $offset ||= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$offset ||= 0
MC/DC0%0/1
$offset ||= 0
$offset
Truth table0%0/2
A
A= $offset
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 0 | ▶ | return $self->_internal_error("Invalid offset for SSL write") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | if $offset>$buf_len; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | ▶ | return 0 if ($offset == $buf_len); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 0 | $SSL_ERROR = $! = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 0 | my $written; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 0 | ▶ | if ( $write_all ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 0 | ▶ | my $data = $length < $buf_len-$offset ? substr($$buffer, $offset, $length) : $$buffer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 0 | ($written, my $errs) = Net::SSLeay::ssl_write_all($ssl, $data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | # ssl_write_all returns number of bytes written | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 0 | ▶ | $written = undef if ! $written && $errs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $written and $errs
MC/DC0%0/2
not $written and $errs
not $written
$errs
Truth table0%0/3
not(A) and B
A= not $writtenB= $errs
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 0 | $written = Net::SSLeay::write_partial( $ssl,$offset,$length,$$buffer ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | # write_partial does SSL_write which returns -1 on error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | 0 | ▶ | $written = undef if $written < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 0 | ▶ | if ( !defined($written) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 0 | ▶ | if ( my $err = $self->_skip_rw_error( $ssl,-1 )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 0 | $self->error("SSL write error"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 0 | return $written; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | # if socket is blocking write() should return only on error or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | # if all data are written | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | sub write { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 0 | ▶ | ${*$self}{_SSL_object} && return _generic_write( $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | scalar($self->blocking),@_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | # fall back to plain write if we are not required to use SSL yet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 0 | return $self->SUPER::write(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | # contrary to write syswrite() returns already if only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | # a part of the data is written | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | sub syswrite { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
syswrite: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 0 | ▶ | ${*$self}{_SSL_object} && return _generic_write($self,0,@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | # fall back to plain syswrite if we are not required to use SSL yet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 0 | return $self->SUPER::syswrite(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | sub print { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 0 | ▶ | my $string = join(($, or ''), @_, ($\ or '')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$, || ''
$\ || ''
MC/DC0%0/1
$, || ''
$,
MC/DC0%0/1
$\ || ''
$\
Truth table0%0/2
A
A= $,
Truth table0%0/2
A
A= $\
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 0 | return $self->write( $string ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | sub printf { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | 0 | ▶ | my ($self,$format) = (shift,shift); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
printf: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 0 | return $self->write(sprintf($format, @_)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | sub getc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 0 | ▶ | my ($self, $buffer) = (shift, undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getc: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 0 | ▶ | return $buffer if $self->read($buffer, 1, 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | sub readline { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readline: not called CC=39 SCAR=73.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 0 | ▶ | if ( not defined $/ or wantarray) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $/ or wantarray
MC/DC0%0/2
not defined $/ or wantarray
not defined $/
wantarray
Truth table0%0/3
not(A) or B
A= not defined $/B= wantarray
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | # read all and split | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 0 | my $buf = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 0 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | 0 | my $rv = $self->sysread($buf,2**16,length($buf)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | 0 | ▶ | if ( ! defined $rv ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 0 | ▶ | next if $!{EINTR}; # retry | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | 0 | ▶ | last if $!{EAGAIN} || $!{EWOULDBLOCK}; # use everything so far | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$!{"EAGAIN"} or $!{"EWOULDBLOCK"}
MC/DC0%0/2
$!{"EAGAIN"} or $!{"EWOULDBLOCK"}
$!{"EAGAIN"}
$!{"EWOULDBLOCK"}
Truth table0%0/3
A or B
A= $!{"EAGAIN"}B= $!{"EWOULDBLOCK"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 0 | return; # return error | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | } elsif ( ! $rv ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | last | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | 0 | ▶ | if ( ! defined $/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 0 | return $buf | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | } elsif ( ref($/)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 0 | my $size = ${$/}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 0 | ▶ | die "bad value in ref \$/: $size" unless $size>0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 0 | return $buf=~m{\G(.{1,$size})}g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | } elsif ( $/ eq '' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | 0 | return $buf =~m{\G(.*\n\n+|.+)}g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 0 | return $buf =~m{\G(.*$/|.+)}g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | # read only one line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 0 | ▶ | if ( ref($/) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 0 | my $size = ${$/}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | # read record of $size bytes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 0 | ▶ | die "bad value in ref \$/: $size" unless $size>0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | 0 | my $buf = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 0 | ▶ | while ( $size>length($buf)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 0 | my $rv = $self->sysread($buf,$size-length($buf),length($buf)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 0 | ▶ | if ( ! defined $rv ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 0 | ▶ | next if $!{EINTR}; # retry | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 0 | ▶ | last if $!{EAGAIN} || $!{EWOULDBLOCK}; # use everything so far | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$!{"EAGAIN"} or $!{"EWOULDBLOCK"}
MC/DC0%0/2
$!{"EAGAIN"} or $!{"EWOULDBLOCK"}
$!{"EAGAIN"}
$!{"EWOULDBLOCK"}
Truth table0%0/3
A or B
A= $!{"EAGAIN"}B= $!{"EWOULDBLOCK"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 0 | return; # return error | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | } elsif ( ! $rv ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | last | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 0 | return $buf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 0 | ▶ | my ($delim0,$delim1) = $/ eq '' ? ("\n\n","\n"):($/,''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | # find first occurrence of $delim0 followed by as much as possible $delim1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 0 | my $buf = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | 0 | my $eod = 0; # pointer into $buf after $delim0 $delim1* | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 0 | ▶ | my $ssl = $self->_get_ssl_object or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 0 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | # wait until we have more data or eof | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 0 | my $poke = Net::SSLeay::peek($ssl,1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 0 | ▶ | if ( ! defined $poke or $poke eq '' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $poke or $poke eq ""
MC/DC0%0/2
not defined $poke or $poke eq ""
not defined $poke
$poke eq ""
Truth table0%0/3
not(A) or B
A= not defined $pokeB= $poke eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 0 | ▶ | next if $!{EINTR}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | 0 | my $skip = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | # peek into available data w/o reading | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 0 | my $pending = Net::SSLeay::pending($ssl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 0 | ▶ | if ( $pending and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pending and (my $pb = &Net::SSLeay::peek($ssl, $pending)) ne ""
MC/DC0%0/2
$pending and (my $pb = &Net::SSLeay::peek($ssl, $pending)) ne ""
$pending
(my $pb = &Net::SSLeay::peek($ssl, $pending)) ne ""
Truth table0%0/3
A and B
A= $pendingB= (my $pb = &Net::SSLeay::peek($ssl, $pending)) ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | ( my $pb = Net::SSLeay::peek( $ssl,$pending )) ne '' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | 0 | $buf .= $pb | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | 0 | ▶ | return $buf eq '' ? ():$buf; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | 0 | ▶ | if ( !$eod ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 0 | my $pos = index( $buf,$delim0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 0 | ▶ | if ( $pos<0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 0 | $skip = $pending | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 0 | $eod = $pos + length($delim0); # pos after delim0 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | 0 | ▶ | if ( $eod ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 0 | ▶ | if ( $delim1 ne '' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | # delim0 found, check for as much delim1 as possible | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 0 | ▶ | while ( index( $buf,$delim1,$eod ) == $eod ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 0 | $eod+= length($delim1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | 0 | $skip = $pending - ( length($buf) - $eod ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | # remove data from $self which I already have in buf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 0 | ▶ | while ( $skip>0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 0 | ▶ | if ($self->sysread(my $p,$skip,0)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 0 | $skip -= length($p); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 0 | ▶ | $!{EINTR} or last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | 0 | ▶ | if ( $eod and ( $delim1 eq '' or $eod < length($buf))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$eod and $delim1 eq "" || $eod < length $buf
$delim1 eq "" or $eod < length $buf
MC/DC0%0/3
$eod and $delim1 eq "" || $eod < length $buf
$eod
$delim1 eq ""
$eod < length $buf
Truth table0%0/4
A and B or C
A= $eodB= $delim1 eq ""C= $eod < length $buf
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | # delim0 found and there can be no more delim1 pending | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | last | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 0 | return substr($buf,0,$eod); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | sub close { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | 14 | ▶ | my $self = shift || return _invalid_object(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
close: called CC=5 SCAR=19.1
Pod
documented
Condition50%1/2
shift() || (return _invalid_object())
MC/DC0%0/1
shift() || (return _invalid_object())
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 14 | ▶ | my $close_args = (ref($_[0]) eq 'HASH') ? $_[0] : {@_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 14 | ▶ | return if ! $self->stop_SSL( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | SSL_fast_shutdown => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | %$close_args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | _SSL_ioclass_downgrade => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | 9 | ▶ | if ( ! $close_args->{_SSL_in_DESTROY} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | 0 | untie( *$self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 0 | undef ${*$self}{_SSL_fileno}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 0 | return $self->SUPER::close; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | 9 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | sub is_SSL { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 0 | ▶ | my $self = pop; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_SSL: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 0 | ▶ | return ${*$self}{_SSL_object} && 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
do {
*$self
}->{'_SSL_object'} && 1
MC/DC0%0/1
do {
*$self
}->{'_SSL_object'} && 1
do {
*$self
}->{'_SSL_object'}
Truth table0%0/2
A
A= do {
*$self
}->{'_SSL_object'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | sub stop_SSL { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 16 | ▶ | my $self = shift || return _invalid_object(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stop_SSL: called CC=27 SCAR=51.1
Pod
documented
Condition50%1/2
shift() || (return _invalid_object())
MC/DC0%0/1
shift() || (return _invalid_object())
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | 16 | ▶ | my $stop_args = (ref($_[0]) eq 'HASH') ? $_[0] : {@_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | 16 | ▶ | $stop_args->{SSL_no_shutdown} = 1 if ! ${*$self}{_SSL_opened}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | 16 | ▶ | if (my $ssl = ${*$self}{'_SSL_object'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | 16 | ▶ | if ( ! $stop_args->{SSL_no_shutdown} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | 7 | my $status = Net::SSLeay::get_shutdown($ssl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | my $timeout = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | not($self->blocking) ? undef : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | exists $stop_args->{Timeout} ? $stop_args->{Timeout} : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 7 | ▶ | ${*$self}{io_socket_timeout}; # from IO::Socket | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | 7 | ▶ | if ($timeout) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 0 | $self->blocking(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | 0 | $timeout += time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 7 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 7 | ▶ | if ( $status & SSL_SENT_SHUTDOWN and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
$status & 1 and $status & 2 || $stop_args->{"SSL_fast_shutdown"}
$status & 2 or $stop_args->{"SSL_fast_shutdown"}
MC/DC0%0/3
$status & 1 and $status & 2 || $stop_args->{"SSL_fast_shutdown"}
$status & 1
$status & 2
$stop_args->{"SSL_fast_shutdown"}
Truth table25%1/4
A and B or C
A= $status & 1B= $status & 2C= $stop_args->{"SSL_fast_shutdown"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | # don't care for received if fast shutdown | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | $status & SSL_RECEIVED_SHUTDOWN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | || $stop_args->{SSL_fast_shutdown}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | # shutdown complete | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | # initiate or complete shutdown | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | 7 | local $SIG{PIPE} = 'IGNORE'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | 7 | my $rv = Net::SSLeay::shutdown($ssl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 7 | ▶ | if ( $rv < 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | # non-blocking socket? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | 7 | ▶ | if ( ! $timeout ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | 7 | $self->_skip_rw_error( $ssl,$rv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | # need to try again | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 7 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | # don't use _skip_rw_error so that existing error does | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | # not get cleared | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | 0 | my $wait = $timeout - time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | 0 | ▶ | last if $wait<=0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | 0 | vec(my $vec = '',fileno($self),1) = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | 0 | my $err = Net::SSLeay::get_error($ssl,$rv); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | 0 | ▶ | if ( $err == Net::SSLeay::ERROR_WANT_READ()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 0 | select($vec,undef,undef,$wait) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | } elsif ( $err == Net::SSLeay::ERROR_WANT_READ()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | 0 | select(undef,$vec,undef,$wait) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | 0 | $status |= SSL_SENT_SHUTDOWN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | 0 | ▶ | $status |= SSL_RECEIVED_SHUTDOWN if $rv>0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | 0 | ▶ | $self->blocking(1) if $timeout; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | # destroy allocated objects for SSL and untie | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | # do not destroy CTX unless explicitly specified | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | 9 | Net::SSLeay::free($ssl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | 9 | delete ${*$self}{_SSL_object}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | 9 | ▶ | if (my $cert = delete ${*$self}{'_SSL_certificate'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | 4 | Net::SSLeay::X509_free($cert); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | 9 | ${*$self}{'_SSL_opened'} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | 9 | untie(*$self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | 9 | ▶ | if ($stop_args->{'SSL_ctx_free'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | 0 | my $ctx = delete ${*$self}{'_SSL_ctx'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | 0 | ▶ | $ctx && $ctx->DESTROY(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | 9 | ▶ | if ( ! $stop_args->{_SSL_in_DESTROY} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | 0 | my $downgrade = $stop_args->{_SSL_ioclass_downgrade}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | 0 | ▶ | if ( $downgrade || ! defined $downgrade ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$downgrade or not defined $downgrade
MC/DC0%0/2
$downgrade or not defined $downgrade
$downgrade
not defined $downgrade
Truth table0%0/3
A or not(B)
A= $downgradeB= not defined $downgrade
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | # rebless to original class from start_SSL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | 0 | ▶ | if ( my $orig_class = delete ${*$self}{'_SSL_ioclass_upgraded'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | 0 | bless $self,$orig_class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | # FIXME: if original class was tied too we need to restore the tie | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | # remove all _SSL related from *$self | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | 0 | my @sslkeys = grep { m{^_?SSL_} } keys %{*$self}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | 0 | ▶ | delete @{*$self}{@sslkeys} if @sslkeys; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | 9 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | sub fileno { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | 14 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fileno: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | 14 | my $fn = ${*$self}{'_SSL_fileno'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | 14 | ▶ | return defined($fn) ? $fn : $self->SUPER::fileno(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | ####### IO::Socket::SSL specific functions ####### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | # _get_ssl_object is for internal use ONLY! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | sub _get_ssl_object { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_ssl_object: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | 4 | ▶ | return ${*$self}{'_SSL_object'} || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
do {
*$self
}->{'_SSL_object'} || 'IO::Socket::SSL'->_internal_error('Undefined SSL object')
MC/DC0%0/2
do {
*$self
}->{'_SSL_object'} || 'IO::Socket::SSL'->_internal_error('Undefined SSL object')
do {
*$self
}->{'_SSL_object'}
'IO::Socket::SSL'->_internal_error('Undefined SSL object')
Truth table33%1/3
A || B
A= do {
*$self
}->{'_SSL_object'}B= 'IO::Socket::SSL'->_internal_error('Undefined SSL object')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | IO::Socket::SSL->_internal_error("Undefined SSL object"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | # _get_ctx_object is for internal use ONLY! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | sub _get_ctx_object { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_ctx_object: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | 0 | my $ctx_object = ${*$self}{_SSL_ctx}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | 0 | ▶ | return $ctx_object && $ctx_object->{context}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ctx_object && $ctx_object->{'context'}
MC/DC0%0/2
$ctx_object && $ctx_object->{'context'}
$ctx_object
$ctx_object->{'context'}
Truth table0%0/3
A && B
A= $ctx_objectB= $ctx_object->{'context'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | # default error for undefined arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | sub _invalid_object { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | 0 | ▶ | return IO::Socket::SSL->_internal_error("Undefined IO::Socket::SSL object"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_invalid_object: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | sub pending { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | 0 | ▶ | my $ssl = shift()->_get_ssl_object || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pending: not called CC=2 SCAR=17.9
Pod
documented
Condition0%0/2
(shift())->_get_ssl_object || (return)
MC/DC0%0/1
(shift())->_get_ssl_object || (return)
(shift())->_get_ssl_object
Truth table0%0/2
A
A= (shift())->_get_ssl_object
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | 0 | return Net::SSLeay::pending($ssl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | sub start_SSL { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | 14 | ▶ | my ($class,$socket) = (shift,shift); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start_SSL: called CC=21 SCAR=33.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | 14 | ▶ | return $class->_internal_error("Not a socket") if ! ref($socket); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | 14 | ▶ | my $arg_hash = (ref($_[0]) eq 'HASH') ? $_[0] : {@_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | 14 | ▶ | my %to = exists $arg_hash->{Timeout} ? ( Timeout => delete $arg_hash->{Timeout} ) :(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | 14 | my $original_class = ref($socket); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | 14 | ▶ | if ( ! $original_class ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | 0 | ▶ | $socket = ($original_class = $ISA[0])->new_from_fd($socket,'<+') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | or return $class->_internal_error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | "creating $original_class from file handle failed"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | 14 | ▶ | my $original_fileno = (UNIVERSAL::can($socket, "fileno")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | ? $socket->fileno : CORE::fileno($socket); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | 14 | ▶ | return $class->_internal_error("Socket has no fileno") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | if ! defined $original_fileno; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | 13 | bless $socket, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | 13 | ▶ | $socket->configure_SSL($arg_hash) or bless($socket, $original_class) && return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
$socket->configure_SSL($arg_hash) || bless($socket, $original_class) && (return)
bless $socket, $original_class and return
MC/DC0%0/2
$socket->configure_SSL($arg_hash) || bless($socket, $original_class) && (return)
$socket->configure_SSL($arg_hash)
bless $socket, $original_class
Truth table66%2/3
A || B
A= $socket->configure_SSL($arg_hash)B= bless $socket, $original_class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | 8 | ${*$socket}{'_SSL_fileno'} = $original_fileno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | 8 | ▶ | ${*$socket}{'_SSL_ioclass_upgraded'} = $original_class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | if $class ne $original_class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | 8 | my $start_handshake = $arg_hash->{SSL_startHandshake}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | 8 | ▶ | if ( ! defined($start_handshake) || $start_handshake ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $start_handshake or $start_handshake
MC/DC50%1/2
not defined $start_handshake or $start_handshake
not defined $start_handshake
$start_handshake
Truth table66%2/3
not(A) or B
A= not defined $start_handshakeB= $start_handshake
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | # if we have no callback force blocking mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | 6 | ▶ | $DEBUG>=2 && DEBUG( "start handshake" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | 6 | my $was_blocking = $socket->blocking(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | 6 | my $result = ${*$socket}{'_SSL_arguments'}{SSL_server} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | 6 | ▶ | ? $socket->accept_SSL(%to) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | : $socket->connect_SSL(%to); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | 6 | ▶ | if ( $result ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | 4 | ▶ | $socket->blocking(0) if ! $was_blocking; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | 4 | return $socket; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | # upgrade to SSL failed, downgrade socket to original class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | 2 | ▶ | if ( $original_class ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | 2 | bless($socket,$original_class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | 2 | ▶ | $socket->blocking(0) if ! $was_blocking | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $was_blocking and $socket->can("blocking")
MC/DC0%0/2
not $was_blocking and $socket->can("blocking")
not $was_blocking
$socket->can("blocking")
Truth table33%1/3
not(A) and B
A= not $was_blockingB= $socket->can("blocking")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | && $socket->can('blocking'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | 2 | ▶ | $DEBUG>=2 && DEBUG( "dont start handshake: $socket" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | 2 | return $socket; # just return upgraded socket | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | sub new_from_fd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | 0 | ▶ | my ($class, $fd) = (shift,shift); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_from_fd: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | # Check for accidental inclusion of MODE in the argument list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | 0 | ▶ | if (length($_[0]) < 4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | 0 | (my $mode = $_[0]) =~ tr/+<>//d; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | 0 | ▶ | shift unless length($mode); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | 0 | ▶ | my $handle = $ISA[0]->new_from_fd($fd, '+<') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$IO::Socket::SSL::ISA[0]->new_from_fd($fd, '+<') || (return $class->error('Could not create socket from file descriptor.'))
MC/DC0%0/1
$IO::Socket::SSL::ISA[0]->new_from_fd($fd, '+<') || (return $class->error('Could not create socket from file descriptor.'))
$IO::Socket::SSL::ISA[0]->new_from_fd($fd, '+<')
Truth table0%0/2
A
A= $IO::Socket::SSL::ISA[0]->new_from_fd($fd, '+<')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | || return($class->error("Could not create socket from file descriptor.")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | # Annoying workaround for Perl 5.6.1 and below: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | 0 | $handle = $ISA[0]->new_from_fd($handle, '+<'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | 0 | return $class->start_SSL($handle, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | sub dump_peer_certificate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | 0 | ▶ | my $ssl = shift()->_get_ssl_object || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_peer_certificate: not called CC=2 SCAR=17.9
Pod
documented
Condition0%0/2
(shift())->_get_ssl_object || (return)
MC/DC0%0/1
(shift())->_get_ssl_object || (return)
(shift())->_get_ssl_object
Truth table0%0/2
A
A= (shift())->_get_ssl_object
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | 0 | return Net::SSLeay::dump_peer_certificate($ssl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | 26 | ▶ | if ( defined &Net::SSLeay::get_peer_cert_chain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &Net::SSLeay::get_peer_cert_chain and $Net::SSLeay::VERSION >= "1.58"
MC/DC0%0/2
defined &Net::SSLeay::get_peer_cert_chain and $Net::SSLeay::VERSION >= "1.58"
defined &Net::SSLeay::get_peer_cert_chain
$Net::SSLeay::VERSION >= "1.58"
Truth table33%1/3
A and B
A= defined &Net::SSLeay::get_peer_cert_chainB= $Net::SSLeay::VERSION >= "1.58"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | && $Net::SSLeay::VERSION >= 1.58 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | *peer_certificates = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | 0 | ▶ | my $ssl = $self->_get_ssl_object || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->_get_ssl_object || (return)
MC/DC0%0/1
$self->_get_ssl_object || (return)
$self->_get_ssl_object
Truth table0%0/2
A
A= $self->_get_ssl_object
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | 0 | my @chain = Net::SSLeay::get_peer_cert_chain($ssl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | 0 | ▶ | @chain = () if @chain && !$self->peer_certificate; # work around #96013 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@chain and not $self->peer_certificate
MC/DC0%0/2
@chain and not $self->peer_certificate
@chain
not $self->peer_certificate
Truth table0%0/3
A and not(B)
A= @chainB= not $self->peer_certificate
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | 0 | ▶ | if ( ${*$self}{_SSL_arguments}{SSL_server} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | # in the client case the chain contains the peer certificate, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | # in the server case not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | # this one has an increased reference counter, the other not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | 0 | ▶ | if ( my $peer = Net::SSLeay::get_peer_certificate($ssl)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | 0 | Net::SSLeay::X509_free($peer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | 0 | unshift @chain, $peer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | 0 | return @chain; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | 26 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | *peer_certificates = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | 0 | ▶ | die "peer_certificates needs Net::SSLeay>=1.58"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | my %dispatcher = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | 0 | ▶ | issuer => sub { Net::SSLeay::X509_NAME_oneline( Net::SSLeay::X509_get_issuer_name( shift )) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | 0 | ▶ | subject => sub { Net::SSLeay::X509_NAME_oneline( Net::SSLeay::X509_get_subject_name( shift )) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | commonName => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | 0 | ▶ | my $cn = Net::SSLeay::X509_NAME_get_text_by_NID( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | Net::SSLeay::X509_get_subject_name( shift ), NID_CommonName); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | 0 | $cn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | 0 | ▶ | subjectAltNames => sub { Net::SSLeay::X509_get_subjectAltNames( shift ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | 26 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | # alternative names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | 26 | $dispatcher{authority} = $dispatcher{issuer}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | 26 | $dispatcher{owner} = $dispatcher{subject}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | 26 | $dispatcher{cn} = $dispatcher{commonName}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | sub peer_certificate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | 4 | ▶ | my ($self,$field,$reload) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
peer_certificate: called CC=8 SCAR=28.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | 4 | ▶ | my $ssl = $self->_get_ssl_object or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | 0 | Net::SSLeay::X509_free(delete ${*$self}{_SSL_certificate}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | 4 | ▶ | if $reload && ${*$self}{_SSL_certificate}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$reload and do {
*$self
}->{"_SSL_certificate"}
MC/DC0%0/2
$reload and do {
*$self
}->{"_SSL_certificate"}
$reload
do {
*$self
}->{"_SSL_certificate"}
Truth table33%1/3
A and B
A= $reloadB= do {
*$self
}->{"_SSL_certificate"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | 4 | my $cert = ${*$self}{_SSL_certificate} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | 4 | ▶ | ||= Net::SSLeay::get_peer_certificate($ssl) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
do {
*$self
}->{"_SSL_certificate"} ||= &Net::SSLeay::get_peer_certificate($ssl)
MC/DC0%0/2
do {
*$self
}->{"_SSL_certificate"} ||= &Net::SSLeay::get_peer_certificate($ssl)
do {
*$self
}->{"_SSL_certificate"}
&Net::SSLeay::get_peer_certificate($ssl)
Truth table33%1/3
A ||= B
A= do {
*$self
}->{"_SSL_certificate"}B= &Net::SSLeay::get_peer_certificate($ssl)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | or return $self->error("Could not retrieve peer certificate"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | 4 | ▶ | if ($field) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | 0 | ▶ | my $sub = $dispatcher{$field} or croak | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | "invalid argument for peer_certificate, valid are: ".join( " ",keys %dispatcher ). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | "\nMaybe you need to upgrade your Net::SSLeay"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | 0 | return $sub->($cert); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | 4 | return $cert | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | # known schemes, possible attributes are: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | # - wildcards_in_alt (0, 'full_label', 'anywhere') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | # - wildcards_in_cn (0, 'full_label', 'anywhere') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | # - check_cn (0, 'always', 'when_only') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | # unfortunately there are a lot of different schemes used, see RFC 6125 for a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | # summary, which references all of the following except RFC4217/ftp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | 26 | my %scheme = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | none => {}, # do not check | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | # default set is a superset of all the others and thus worse than a more | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | # specific set, but much better than not verifying name at all | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | default => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | wildcards_in_cn => 'anywhere', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | wildcards_in_alt => 'anywhere', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | check_cn => 'always', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | ip_in_cn => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | 26 | for(qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | rfc2818 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | rfc3920 xmpp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | rfc4217 ftp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | 130 | $scheme{$_} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | wildcards_in_cn => 'anywhere', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | wildcards_in_alt => 'anywhere', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | check_cn => 'when_only', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | 26 | for(qw(www http)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | 52 | $scheme{$_} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | wildcards_in_cn => 'anywhere', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | wildcards_in_alt => 'anywhere', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | check_cn => 'when_only', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | ip_in_cn => 4, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | 26 | for(qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | rfc4513 ldap | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | 52 | $scheme{$_} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | wildcards_in_cn => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | wildcards_in_alt => 'full_label', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | check_cn => 'always', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | 26 | for(qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | rfc2595 smtp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | rfc4642 imap pop3 acap | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | rfc5539 nntp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | rfc5538 netconf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | rfc5425 syslog | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | rfc5953 snmp | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | 364 | $scheme{$_} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | wildcards_in_cn => 'full_label', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | wildcards_in_alt => 'full_label', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | check_cn => 'always' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | 26 | for(qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | rfc5971 gist | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | 52 | $scheme{$_} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | wildcards_in_cn => 'full_label', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | wildcards_in_alt => 'full_label', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | check_cn => 'when_only', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | 26 | for(qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | rfc5922 sip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | 52 | $scheme{$_} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | wildcards_in_cn => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | wildcards_in_alt => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | check_cn => 'always', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | # function to verify the hostname | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | # as every application protocol has its own rules to do this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | # we provide some default rules as well as a user-defined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | # callback | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | sub verify_hostname_of_cert { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | 0 | ▶ | my $identity = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verify_hostname_of_cert: not called CC=35 SCAR=71.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | 0 | my $cert = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | 0 | ▶ | my $scheme = shift || 'default'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 'default'
MC/DC0%0/1
shift() || 'default'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | 0 | my $publicsuffix = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | 0 | ▶ | if ( ! ref($scheme) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | 0 | ▶ | $DEBUG>=3 && DEBUG( "scheme=$scheme cert=$cert" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | 0 | ▶ | $scheme = $scheme{$scheme} or croak "scheme $scheme not defined"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | 0 | ▶ | return 1 if ! %$scheme; # 'none' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | 0 | $identity =~s{\.+$}{}; # ignore absolutism | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | # get data from certificate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | 0 | my $commonName = $dispatcher{cn}->($cert); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | 0 | my @altNames = $dispatcher{subjectAltNames}->($cert); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | 0 | ▶ | $DEBUG>=3 && DEBUG("identity=$identity cn=$commonName alt=@altNames" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | 0 | ▶ | if ( my $sub = $scheme->{callback} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | # use custom callback | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | 0 | return $sub->($identity,$commonName,@altNames); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | # is the given hostname an IP address? Then we have to convert to network byte order [RFC791][RFC2460] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | 0 | my $ipn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | 0 | ▶ | if ( CAN_IPV6 and $identity =~m{:} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | # no IPv4 or hostname have ':' in it, try IPv6. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | 0 | ▶ | $ipn = inet_pton(AF_INET6,$identity) or return; # invalid name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | } elsif ( my @ip = $identity =~m{^(\d+)(?:\.(\d+)\.(\d+)\.(\d+)|[\d\.]*)$} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | # check for invalid IP/hostname | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | 0 | ▶ | return if 4 != @ip or 4 != grep { defined($_) && $_<256 } @ip; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
4 != @ip or 4 != grep({defined $_ and $_ < 256;} @ip)
MC/DC0%0/2
4 != @ip or 4 != grep({defined $_ and $_ < 256;} @ip)
4 != @ip
4 != grep({defined $_ and $_ < 256;} @ip)
Truth table0%0/3
A or B
A= 4 != @ipB= 4 != grep({defined $_ and $_ < 256;} @ip)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | 0 | $ipn = pack("CCCC",@ip); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | # assume hostname, check for umlauts etc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | 0 | ▶ | if ( $identity =~m{[^a-zA-Z0-9_.\-]} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | 0 | ▶ | $identity =~m{\0} and return; # $identity has \\0 byte | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | 0 | ▶ | $identity = idn_to_ascii($identity) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | or return; # conversation to IDNA failed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | 0 | ▶ | $identity =~m{[^a-zA-Z0-9_.\-]} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | and return; # still junk inside | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | # do the actual verification | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | my $check_name = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | 0 | ▶ | my ($name,$identity,$wtyp,$publicsuffix) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=14 SCAR=53.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | 0 | $name =~s{\.+$}{}; # ignore absolutism | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | 0 | ▶ | $name eq '' and return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | 0 | ▶ | $wtyp ||= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$wtyp ||= ""
MC/DC0%0/1
$wtyp ||= ""
$wtyp
Truth table0%0/2
A
A= $wtyp
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | 0 | my $pattern; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | ### IMPORTANT! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | # We accept only a single wildcard and only for a single part of the FQDN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | # e.g *.example.org does match www.example.org but not bla.www.example.org | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | # The RFCs are in this regard unspecific but we don't want to have to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | # deal with certificates like *.com, *.co.uk or even * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | # see also http://nils.toedtmann.net/pub/subjectAltName.txt . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | # Also, we fall back to full_label matches if the identity is an IDNA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | # name, see RFC6125 and the discussion at | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | # http://bugs.python.org/issue17997#msg194950 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | 0 | ▶ | if ( $wtyp eq 'anywhere' and $name =~m{^([a-zA-Z0-9_\-]*)\*(.+)} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$wtyp eq "anywhere" and $name =~ /^([a-zA-Z0-9_\-]*)\*(.+)/
MC/DC0%0/2
$wtyp eq "anywhere" and $name =~ /^([a-zA-Z0-9_\-]*)\*(.+)/
$wtyp eq "anywhere"
$name =~ /^([a-zA-Z0-9_\-]*)\*(.+)/
Truth table0%0/3
A and B
A= $wtyp eq "anywhere"B= $name =~ /^([a-zA-Z0-9_\-]*)\*(.+)/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | 0 | ▶ | return if $1 ne '' and substr($identity,0,4) eq 'xn--'; # IDNA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$1 ne "" and substr($identity, 0, 4) eq "xn--"
MC/DC0%0/2
$1 ne "" and substr($identity, 0, 4) eq "xn--"
$1 ne ""
substr($identity, 0, 4) eq "xn--"
Truth table0%0/3
A and B
A= $1 ne ""B= substr($identity, 0, 4) eq "xn--"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | 0 | $pattern = qr{^\Q$1\E[a-zA-Z0-9_\-]+\Q$2\E$}i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | ▶ | } elsif ( $wtyp =~ m{^(?:full_label|leftmost)$} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$wtyp =~ /^(?:full_label|leftmost)$/ and $name =~ /^\*(\..+)$/
MC/DC0%0/2
$wtyp =~ /^(?:full_label|leftmost)$/ and $name =~ /^\*(\..+)$/
$wtyp =~ /^(?:full_label|leftmost)$/
$name =~ /^\*(\..+)$/
Truth table0%0/3
A and B
A= $wtyp =~ /^(?:full_label|leftmost)$/B= $name =~ /^\*(\..+)$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | and $name =~m{^\*(\..+)$} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | 0 | $pattern = qr{^[a-zA-Z0-9_\-]+\Q$1\E$}i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | 0 | return lc($identity) eq lc($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | 0 | ▶ | if ( $identity =~ $pattern ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | 0 | ▶ | $publicsuffix = IO::Socket::SSL::PublicSuffix->default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | if ! defined $publicsuffix; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | 0 | ▶ | return 1 if $publicsuffix eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | 0 | my @labels = split( m{\.+}, $identity ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | 0 | my $tld = $publicsuffix->public_suffix(\@labels,+1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | 0 | ▶ | return 1 if @labels > ( $tld ? 0+@$tld : 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | 0 | my $alt_dnsNames = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | 0 | ▶ | while (@altNames) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | 0 | my ($type, $name) = splice (@altNames, 0, 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | 0 | ▶ | if ( $ipn and $type == GEN_IPADD ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$ipn and $type == GEN_IPADD()
MC/DC0%0/2
$ipn and $type == GEN_IPADD()
$ipn
$type == GEN_IPADD()
Truth table0%0/3
A and B
A= $ipnB= $type == GEN_IPADD()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | # exact match needed for IP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | # $name is already packed format (inet_xton) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | 0 | ▶ | return 1 if $ipn eq $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | ▶ | } elsif ( ! $ipn and $type == GEN_DNS ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
not $ipn and $type == GEN_DNS()
MC/DC0%0/2
not $ipn and $type == GEN_DNS()
not $ipn
$type == GEN_DNS()
Truth table0%0/3
not(A) and B
A= not $ipnB= $type == GEN_DNS()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | 0 | $name =~s/\s+$//; $name =~s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | 0 | $alt_dnsNames++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | 0 | ▶ | $check_name->($name,$identity,$scheme->{wildcards_in_alt},$publicsuffix) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | and return 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | 0 | ▶ | if ( $scheme->{check_cn} eq 'always' or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$scheme->{"check_cn"} eq "always" or $scheme->{"check_cn"} eq "when_only" and not $alt_dnsNames
$scheme->{"check_cn"} eq "when_only" and not $alt_dnsNames
MC/DC0%0/3
$scheme->{"check_cn"} eq "always" or $scheme->{"check_cn"} eq "when_only" and not $alt_dnsNames
$scheme->{"check_cn"} eq "always"
$scheme->{"check_cn"} eq "when_only"
not $alt_dnsNames
Truth table0%0/4
A or B and not(C)
A= $scheme->{"check_cn"} eq "always"B= $scheme->{"check_cn"} eq "when_only"C= not $alt_dnsNames
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | $scheme->{check_cn} eq 'when_only' and !$alt_dnsNames ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | 0 | ▶ | if ( ! $ipn ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | 0 | ▶ | $check_name->($commonName,$identity,$scheme->{wildcards_in_cn},$publicsuffix) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | and return 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | } elsif ( $scheme->{ip_in_cn} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | 0 | ▶ | if ( $identity eq $commonName ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | return 1 if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | $scheme->{ip_in_cn} == 4 ? length($ipn) == 4 : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | 0 | ▶ | $scheme->{ip_in_cn} == 6 ? length($ipn) == 8 : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | 0 | return 0; # no match | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | 26 | sub verify_hostname { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verify_hostname: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | 0 | my $host = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | 0 | my $cert = $self->peer_certificate; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | 0 | return verify_hostname_of_cert( $host,$cert,@_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | sub get_servername { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_servername: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | 0 | ▶ | return ${*$self}{_SSL_servername} ||= do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
do {
*$self
}->{"_SSL_servername"} ||= do {
my $ssl = $self->_get_ssl_object or return;
&Net::SSLeay::get_servername($ssl)
}
MC/DC0%0/2
do {
*$self
}->{"_SSL_servername"} ||= do {
my $ssl = $self->_get_ssl_object or return;
&Net::SSLeay::get_servername($ssl)
}
do {
*$self
}->{"_SSL_servername"}
do {
my $ssl = $self->_get_ssl_object or return;
&Net::SSLeay::get_servername($ssl)
}
Truth table0%0/3
A ||= B
A= do {
*$self
}->{"_SSL_servername"}B= do {
my $ssl = $self->_get_ssl_object or return;
&Net::SSLeay::get_servername($ssl)
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | 0 | ▶ | my $ssl = $self->_get_ssl_object or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | 0 | Net::SSLeay::get_servername($ssl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | sub get_fingerprint_bin { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | 4 | ▶ | my $cert = shift()->peer_certificate; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_fingerprint_bin: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | 4 | ▶ | return Net::SSLeay::X509_digest($cert, $algo2digest->(shift() || 'sha256')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || 'sha256'
MC/DC0%0/1
shift() || 'sha256'
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | sub get_fingerprint { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | 4 | ▶ | my ($self,$algo) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_fingerprint: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | 4 | ▶ | $algo ||= 'sha256'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$algo ||= "sha256"
MC/DC0%0/1
$algo ||= "sha256"
$algo
Truth table50%1/2
A
A= $algo
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | 4 | ▶ | my $fp = get_fingerprint_bin($self,$algo) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | 4 | return $algo.'$'.unpack('H*',$fp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | sub get_cipher { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | 0 | ▶ | my $ssl = shift()->_get_ssl_object || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_cipher: not called CC=2 SCAR=17.9
Pod
documented
Condition0%0/2
(shift())->_get_ssl_object || (return)
MC/DC0%0/1
(shift())->_get_ssl_object || (return)
(shift())->_get_ssl_object
Truth table0%0/2
A
A= (shift())->_get_ssl_object
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | 0 | return Net::SSLeay::get_cipher($ssl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | sub get_sslversion { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | 0 | ▶ | my $ssl = shift()->_get_ssl_object || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_sslversion: not called CC=9 SCAR=45.0
Pod
documented
Condition0%0/2
(shift())->_get_ssl_object || (return)
MC/DC0%0/1
(shift())->_get_ssl_object || (return)
(shift())->_get_ssl_object
Truth table0%0/2
A
A= (shift())->_get_ssl_object
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | 0 | ▶ | my $version = Net::SSLeay::version($ssl) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | 0 | ▶ | $version == 0x0303 ? 'TLSv1_2' : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | $version == 0x0302 ? 'TLSv1_1' : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | $version == 0x0301 ? 'TLSv1' : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | $version == 0x0300 ? 'SSLv3' : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | $version == 0x0002 ? 'SSLv2' : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | $version == 0xfeff ? 'DTLS1' : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | sub get_sslversion_int { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | 0 | ▶ | my $ssl = shift()->_get_ssl_object || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_sslversion_int: not called CC=2 SCAR=17.9
Pod
documented
Condition0%0/2
(shift())->_get_ssl_object || (return)
MC/DC0%0/1
(shift())->_get_ssl_object || (return)
(shift())->_get_ssl_object
Truth table0%0/2
A
A= (shift())->_get_ssl_object
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | 0 | return Net::SSLeay::version($ssl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1717 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1719 | 26 | ▶ | if ($can_ocsp) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1720 | 26 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1721 | *ocsp_resolver = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1722 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | 0 | ▶ | my $ssl = $self->_get_ssl_object || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->_get_ssl_object || (return)
MC/DC0%0/1
$self->_get_ssl_object || (return)
$self->_get_ssl_object
Truth table0%0/2
A
A= $self->_get_ssl_object
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | 0 | my $ctx = ${*$self}{_SSL_ctx}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1725 | return IO::Socket::SSL::OCSP_Resolver->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | $ssl, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1727 | $ctx->{ocsp_cache} ||= IO::Socket::SSL::OCSP_Cache->new, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1728 | $ctx->{ocsp_mode} & SSL_OCSP_FAIL_HARD, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1729 | @_ ? \@_ : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1730 | 0 | ▶ | $ctx->{ocsp_mode} & SSL_OCSP_FULL_CHAIN ? [ $self->peer_certificates ]: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$ctx->{"ocsp_cache"} ||= "IO::Socket::SSL::OCSP_Cache"->new
MC/DC0%0/2
$ctx->{"ocsp_cache"} ||= "IO::Socket::SSL::OCSP_Cache"->new
$ctx->{"ocsp_cache"}
"IO::Socket::SSL::OCSP_Cache"->new
Truth table0%0/3
A ||= B
A= $ctx->{"ocsp_cache"}B= "IO::Socket::SSL::OCSP_Cache"->new
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1731 | [ $self->peer_certificate ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1732 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1733 | 26 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1734 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1735 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1736 | sub errstr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1737 | 7 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
errstr: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1738 | 7 | ▶ | return (ref($self) ? ${*$self}{'_SSL_last_err'} : $SSL_ERROR) || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
(ref $self ? do {
*$self
}->{'_SSL_last_err'} : $IO::Socket::SSL::SSL_ERROR) || ''
MC/DC0%0/1
(ref $self ? do {
*$self
}->{'_SSL_last_err'} : $IO::Socket::SSL::SSL_ERROR) || ''
(ref $self ? do {
*$self
}->{'_SSL_last_err'} : $IO::Socket::SSL::SSL_ERROR)
Truth table50%1/2
A
A= (ref $self ? do {
*$self
}->{'_SSL_last_err'} : $IO::Socket::SSL::SSL_ERROR)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1739 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1741 | sub fatal_ssl_error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1742 | 7 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fatal_ssl_error: called CC=4 SCAR=14.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1743 | 7 | my $error_trap = ${*$self}{'_SSL_arguments'}->{'SSL_error_trap'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1744 | 7 | $@ = $self->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1745 | 7 | ▶ | if (defined $error_trap and ref($error_trap) eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
defined $error_trap and ref $error_trap eq "CODE"
MC/DC0%0/2
defined $error_trap and ref $error_trap eq "CODE"
defined $error_trap
ref $error_trap eq "CODE"
Truth table33%1/3
A and B
A= defined $error_trapB= ref $error_trap eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1746 | 0 | $error_trap->($self, $self->errstr()."\n".$self->get_ssleay_error()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1747 | 7 | } elsif ( ${*$self}{'_SSL_ioclass_upgraded'} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1748 | # downgrade only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1749 | 2 | $self->stop_SSL; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1750 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1751 | # kill socket | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1752 | 5 | $self->close | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1753 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1754 | 7 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1755 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1756 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1757 | sub get_ssleay_error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1758 | #Net::SSLeay will print out the errors itself unless we explicitly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1759 | #undefine $Net::SSLeay::trace while running print_errs() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1760 | 0 | ▶ | local $Net::SSLeay::trace; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_ssleay_error: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1761 | 0 | ▶ | return Net::SSLeay::print_errs('SSL error: ') || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
Net::SSLeay::print_errs('SSL error: ') || ''
MC/DC0%0/1
Net::SSLeay::print_errs('SSL error: ') || ''
Net::SSLeay::print_errs('SSL error: ')
Truth table0%0/2
A
A= Net::SSLeay::print_errs('SSL error: ')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1762 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1763 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1764 | # internal errors, e.g unsupported features etc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1765 | sub _internal_error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1766 | 3 | ▶ | my ($self, $error, $destroy_socket) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_internal_error: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1767 | 3 | $SSL_ERROR = dualvar( -1, $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1768 | 3 | ▶ | $DEBUG && DEBUG($error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1769 | 3 | ▶ | ${*$self}{'_SSL_last_err'} = $SSL_ERROR if (ref($self)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1770 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1771 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1772 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1773 | # OpenSSL errors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1774 | sub error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1775 | 23 | ▶ | my ($self, $error, $destroy_socket) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1776 | 23 | my @err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1777 | 23 | ▶ | while ( my $err = Net::SSLeay::ERR_get_error()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1778 | 105 | push @err, Net::SSLeay::ERR_error_string($err); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1779 | 105 | ▶ | $DEBUG>=2 && DEBUG( $error."\n".$self->get_ssleay_error()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1780 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1781 | 23 | ▶ | $error .= ' '.join(' ',@err) if @err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1782 | 23 | ▶ | if ($error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1783 | 23 | $SSL_ERROR = dualvar( -1, $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1784 | 23 | ▶ | $DEBUG && DEBUG($error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1785 | 23 | ▶ | ${*$self}{'_SSL_last_err'} = $SSL_ERROR if (ref($self)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1786 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1787 | 23 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1788 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1789 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1790 | 1 | ▶ | sub can_client_sni { return $can_client_sni } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
can_client_sni: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1791 | 0 | ▶ | sub can_server_sni { return $can_server_sni } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
can_server_sni: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1792 | 1 | ▶ | sub can_npn { return $can_npn } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
can_npn: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1793 | 1 | ▶ | sub can_ecdh { return $can_ecdh } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
can_ecdh: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1794 | 0 | ▶ | sub can_ipv6 { return CAN_IPV6 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
can_ipv6: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1795 | 1 | ▶ | sub can_ocsp { return $can_ocsp } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
can_ocsp: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1796 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1797 | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1798 | 27 | ▶ | my $self = shift or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=5 SCAR=16.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1799 | 27 | ▶ | my $ssl = ${*$self}{_SSL_object} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1800 | 11 | delete $SSL_OBJECT{$ssl}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1801 | 11 | ▶ | if ($CREATED_IN_THIS_THREAD{$ssl}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1802 | $self->close(_SSL_in_DESTROY => 1, SSL_no_shutdown => 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1803 | 11 | ▶ | if ${*$self}{'_SSL_opened'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1804 | 11 | delete(${*$self}{'_SSL_ctx'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1805 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1806 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1807 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1808 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1809 | #######Extra Backwards Compatibility Functionality####### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1810 | 1 | ▶ | sub socket_to_SSL { IO::Socket::SSL->start_SSL(@_); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
socket_to_SSL: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1811 | 1 | ▶ | sub socketToSSL { IO::Socket::SSL->start_SSL(@_); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
socketToSSL: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1812 | 0 | ▶ | sub kill_socket { shift->close } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
kill_socket: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1813 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1814 | 0 | ▶ | sub issuer_name { return(shift()->peer_certificate("issuer")) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
issuer_name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1815 | 0 | ▶ | sub subject_name { return(shift()->peer_certificate("subject")) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subject_name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1816 | 0 | ▶ | sub get_peer_certificate { return shift() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_peer_certificate: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1817 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1818 | sub context_init { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1819 | 2 | ▶ | return($GLOBAL_SSL_ARGS = (ref($_[0]) eq 'HASH') ? $_[0] : {@_}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
context_init: called CC=2 SCAR=7.6
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1820 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1821 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1822 | sub set_default_context { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1823 | 0 | ▶ | $GLOBAL_SSL_ARGS->{'SSL_reuse_ctx'} = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_default_context: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1824 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1825 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1826 | sub set_default_session_cache { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1827 | 0 | ▶ | $GLOBAL_SSL_ARGS->{SSL_session_cache} = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_default_session_cache: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1828 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1829 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1830 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1831 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1832 | my $set_defaults = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1833 | 0 | ▶ | my $args = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1834 | 0 | ▶ | for(my $i=0;$i<@$args;$i+=2 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1835 | 0 | my ($k,$v) = @{$args}[$i,$i+1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1836 | 0 | ▶ | if ( $k =~m{^SSL_} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1837 | 0 | $_->{$k} = $v for(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1838 | } elsif ( $k =~m{^(name|scheme)$} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1839 | 0 | $_->{"SSL_verifycn_$k"} = $v for (@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1840 | } elsif ( $k =~m{^(callback|mode)$} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1841 | 0 | $_->{"SSL_verify_$k"} = $v for(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1842 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1843 | 0 | $_->{"SSL_$k"} = $v for(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1844 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1845 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1846 | 26 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1847 | sub set_defaults { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1848 | 0 | ▶ | my %args = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_defaults: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1849 | 0 | $set_defaults->(\@_, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1850 | $GLOBAL_SSL_ARGS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1851 | $GLOBAL_SSL_CLIENT_ARGS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1852 | $GLOBAL_SSL_SERVER_ARGS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1853 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1854 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1855 | { # deprecated API | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1856 | 26 | ▶ | no warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1857 | 26 | *set_ctx_defaults = \&set_defaults; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1858 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1859 | sub set_client_defaults { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1860 | 0 | ▶ | my %args = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_client_defaults: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1861 | 0 | $set_defaults->(\@_, $GLOBAL_SSL_CLIENT_ARGS ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1862 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1863 | sub set_server_defaults { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1864 | 0 | ▶ | my %args = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_server_defaults: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1865 | 0 | $set_defaults->(\@_, $GLOBAL_SSL_SERVER_ARGS ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1866 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1867 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1868 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1869 | 26 | sub set_args_filter_hack { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1870 | 0 | ▶ | my $sub = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_args_filter_hack: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1871 | 0 | ▶ | if ( ref $sub ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1872 | 0 | $FILTER_SSL_ARGS = $sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1873 | } elsif ( $sub eq 'use_defaults' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1874 | # override args with defaults | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1875 | $FILTER_SSL_ARGS = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1876 | 0 | ▶ | my ($is_server,$args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1877 | 0 | ▶ | %$args = ( %$args, $is_server | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1878 | ? ( %DEFAULT_SSL_SERVER_ARGS, %$GLOBAL_SSL_SERVER_ARGS ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1879 | : ( %DEFAULT_SSL_CLIENT_ARGS, %$GLOBAL_SSL_CLIENT_ARGS ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1880 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1881 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1882 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1883 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1884 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1885 | sub next_proto_negotiated { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1886 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_proto_negotiated: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1887 | 0 | ▶ | return $self->_internal_error("NPN not supported in Net::SSLeay") if ! $can_npn; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1888 | 0 | ▶ | my $ssl = $self->_get_ssl_object || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->_get_ssl_object || (return)
MC/DC0%0/1
$self->_get_ssl_object || (return)
$self->_get_ssl_object
Truth table0%0/2
A
A= $self->_get_ssl_object
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1889 | 0 | return Net::SSLeay::P_next_proto_negotiated($ssl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1890 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1891 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1892 | sub opened { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1893 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
opened: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1894 | 0 | ▶ | return IO::Handle::opened($self) && ${*$self}{'_SSL_opened'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
IO::Handle::opened($self) && do {
*$self
}->{'_SSL_opened'}
MC/DC0%0/2
IO::Handle::opened($self) && do {
*$self
}->{'_SSL_opened'}
IO::Handle::opened($self)
do {
*$self
}->{'_SSL_opened'}
Truth table0%0/3
A && B
A= IO::Handle::opened($self)B= do {
*$self
}->{'_SSL_opened'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1895 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1896 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1897 | sub opening { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1898 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
opening: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1899 | 0 | return ${*$self}{'_SSL_opening'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1900 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1901 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1902 | 0 | ▶ | sub want_read { shift->errstr == SSL_WANT_READ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
want_read: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1903 | 0 | ▶ | sub want_write { shift->errstr == SSL_WANT_WRITE } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
want_write: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1904 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1905 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1906 | #Redundant IO::Handle functionality | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1907 | 0 | ▶ | sub getline { return(scalar shift->readline()) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getline: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1908 | sub getlines { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1909 | 0 | ▶ | return(shift->readline()) if wantarray(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getlines: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1910 | 0 | croak("Use of getlines() not allowed in scalar context"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1911 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1912 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1913 | #Useless IO::Handle functionality | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1914 | 0 | ▶ | sub truncate { croak("Use of truncate() not allowed with SSL") } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
truncate: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1915 | 0 | ▶ | sub stat { croak("Use of stat() not allowed with SSL" ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stat: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1916 | 0 | ▶ | sub setbuf { croak("Use of setbuf() not allowed with SSL" ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setbuf: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1917 | 0 | ▶ | sub setvbuf { croak("Use of setvbuf() not allowed with SSL" ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setvbuf: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1918 | 0 | ▶ | sub fdopen { croak("Use of fdopen() not allowed with SSL" ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fdopen: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1919 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1920 | #Unsupported socket functionality | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1921 | 0 | ▶ | sub ungetc { croak("Use of ungetc() not implemented in IO::Socket::SSL") } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ungetc: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1922 | 0 | ▶ | sub send { croak("Use of send() not implemented in IO::Socket::SSL; use print/printf/syswrite instead") } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1923 | 0 | ▶ | sub recv { croak("Use of recv() not implemented in IO::Socket::SSL; use read/sysread instead") } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
recv: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1924 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1925 | package IO::Socket::SSL::SSL_HANDLE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1926 | 26 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1927 | 26 | ▶ | use Errno 'EBADF'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1928 | 26 | *weaken = *IO::Socket::SSL::weaken; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1929 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1930 | sub TIEHANDLE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1931 | 4 | ▶ | my ($class, $handle) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TIEHANDLE: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1932 | 4 | weaken($handle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1933 | 4 | bless \$handle, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1934 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1935 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1936 | 0 | ▶ | sub READ { ${shift()}->sysread(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
READ: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1937 | 0 | ▶ | sub READLINE { ${shift()}->readline(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
READLINE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1938 | 0 | ▶ | sub GETC { ${shift()}->getc(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
GETC: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1939 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1940 | 0 | ▶ | sub PRINT { ${shift()}->print(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
PRINT: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1941 | 0 | ▶ | sub PRINTF { ${shift()}->printf(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
PRINTF: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1942 | 0 | ▶ | sub WRITE { ${shift()}->syswrite(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
WRITE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1943 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1944 | 0 | ▶ | sub FILENO { ${shift()}->fileno(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FILENO: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1945 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1946 | 0 | ▶ | sub TELL { $! = EBADF; return -1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TELL: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1947 | 0 | ▶ | sub BINMODE { return 0 } # not perfect, but better than not implementing the method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BINMODE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1948 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1949 | sub CLOSE { #<---- Do not change this function! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1950 | 0 | ▶ | my $ssl = ${$_[0]}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CLOSE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1951 | 0 | local @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1952 | 0 | $ssl->close(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1953 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1954 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1955 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1956 | package IO::Socket::SSL::SSL_Context; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1957 | 26 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1958 | 26 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1959 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1960 | 26 | my %CTX_CREATED_IN_THIS_THREAD; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1961 | 26 | *DEBUG = *IO::Socket::SSL::DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1962 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1963 | 26 | ▶ | use constant SSL_MODE_ENABLE_PARTIAL_WRITE => 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1964 | 26 | ▶ | use constant SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER => 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1965 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1966 | 26 | ▶ | use constant FILETYPE_PEM => Net::SSLeay::FILETYPE_PEM(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1967 | 26 | ▶ | use constant FILETYPE_ASN1 => Net::SSLeay::FILETYPE_ASN1(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1968 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1969 | # Note that the final object will actually be a reference to the scalar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1970 | # (C-style pointer) returned by Net::SSLeay::CTX_*_new() so that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1971 | # it can be blessed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1972 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1973 | 30 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=173 SCAR=90.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1974 | #DEBUG( "$class @_" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1975 | 30 | ▶ | my $arg_hash = (ref($_[0]) eq 'HASH') ? $_[0] : {@_}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1976 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1977 | # common problem forgetting to set SSL_use_cert | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1978 | # if client cert is given by user but SSL_use_cert is undef, assume that it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1979 | # should be set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1980 | 30 | my $is_server = $arg_hash->{SSL_server}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1981 | 30 | ▶ | if ( ! $is_server && ! defined $arg_hash->{SSL_use_cert} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
not $is_server || defined $arg_hash->{"SSL_use_cert"} and grep {$arg_hash->{$_};} "SSL_cert", "SSL_cert_file" and grep {$arg_hash->{$_};} "SSL_key", "SSL_key_file"
not $is_server || defined $arg_hash->{"SSL_use_cert"} and grep {$arg_hash->{$_};} "SSL_cert", "SSL_cert_file"
$is_server || defined $arg_hash->{'SSL_use_cert'}
MC/DC0%0/4
not $is_server || defined $arg_hash->{"SSL_use_cert"} and grep {$arg_hash->{$_};} "SSL_cert", "SSL_cert_file" and grep {$arg_hash->{$_};} "SSL_key", "SSL_key_file"
$is_server
defined $arg_hash->{'SSL_use_cert'}
grep {$arg_hash->{$_};} "SSL_cert", "SSL_cert_file"
grep {$arg_hash->{$_};} "SSL_key", "SSL_key_file"
Truth table40%2/5
not(A || B) and C and D
A= $is_serverB= defined $arg_hash->{'SSL_use_cert'}C= grep {$arg_hash->{$_};} "SSL_cert", "SSL_cert_file"D= grep {$arg_hash->{$_};} "SSL_key", "SSL_key_file"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1982 | 20 | && ( grep { $arg_hash->{$_} } qw(SSL_cert SSL_cert_file)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1983 | 0 | && ( grep { $arg_hash->{$_} } qw(SSL_key SSL_key_file)) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1984 | 0 | $arg_hash->{SSL_use_cert} = 1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1985 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1986 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1987 | # if any of SSL_ca* is set don't set the other SSL_ca* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1988 | # from defaults | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1989 | 30 | ▶ | if ( $arg_hash->{SSL_ca} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1990 | $arg_hash->{SSL_ca_file} ||= undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1991 | $arg_hash->{SSL_ca_path} ||= undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1992 | 0 | ▶ | } elsif ( $arg_hash->{SSL_ca_path} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$arg_hash->{"SSL_ca_file"} ||= (undef $arg_hash->{"SSL_ca_path"} ||= undef)
undef $arg_hash->{"SSL_ca_path"} ||= undef
MC/DC0%0/2
$arg_hash->{"SSL_ca_file"} ||= (undef $arg_hash->{"SSL_ca_path"} ||= undef)
$arg_hash->{"SSL_ca_file"}
(undef $arg_hash->{"SSL_ca_path"} ||= undef)
MC/DC0%0/1
undef $arg_hash->{"SSL_ca_path"} ||= undef
undef $arg_hash->{"SSL_ca_path"}
Truth table0%0/3
A ||= B
A= $arg_hash->{"SSL_ca_file"}B= (undef $arg_hash->{"SSL_ca_path"} ||= undef)
Truth table0%0/2
A
A= undef $arg_hash->{"SSL_ca_path"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1993 | $arg_hash->{SSL_ca_file} ||= undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1994 | 0 | ▶ | } elsif ( $arg_hash->{SSL_ca_file} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$arg_hash->{"SSL_ca_file"} ||= undef
MC/DC0%0/1
$arg_hash->{"SSL_ca_file"} ||= undef
$arg_hash->{"SSL_ca_file"}
Truth table0%0/2
A
A= $arg_hash->{"SSL_ca_file"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1995 | 8 | ▶ | $arg_hash->{SSL_ca_path} ||= undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$arg_hash->{"SSL_ca_path"} ||= undef
MC/DC0%0/1
$arg_hash->{"SSL_ca_path"} ||= undef
$arg_hash->{"SSL_ca_path"}
Truth table50%1/2
A
A= $arg_hash->{"SSL_ca_path"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1996 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1997 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1998 | # add library defaults | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1999 | 30 | ▶ | %$arg_hash = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2000 | SSL_use_cert => $is_server, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2001 | $is_server ? %DEFAULT_SSL_SERVER_ARGS : %DEFAULT_SSL_CLIENT_ARGS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2002 | %$arg_hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2003 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2004 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2005 | # Avoid passing undef arguments to Net::SSLeay | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2006 | 30 | ▶ | defined($arg_hash->{$_}) or delete($arg_hash->{$_}) for(keys %$arg_hash); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2007 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2008 | # check SSL CA, cert etc arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2009 | # some apps set keys '' to signal that it is not set, replace with undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2010 | 30 | for (qw( SSL_cert SSL_cert_file SSL_key SSL_key_file | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2011 | SSL_ca SSL_ca_file SSL_ca_path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2012 | SSL_fingerprint )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2013 | $arg_hash->{$_} = undef if defined $arg_hash->{$_} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2014 | 240 | ▶ | and $arg_hash->{$_} eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $arg_hash->{$_} and $arg_hash->{$_} eq ""
MC/DC0%0/2
defined $arg_hash->{$_} and $arg_hash->{$_} eq ""
defined $arg_hash->{$_}
$arg_hash->{$_} eq ""
Truth table66%2/3
A and B
A= defined $arg_hash->{$_}B= $arg_hash->{$_} eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2015 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2016 | 30 | for(qw(SSL_cert_file SSL_key_file)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2017 | 60 | ▶ | defined( my $file = $arg_hash->{$_} ) or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2018 | 37 | ▶ | for my $f (ref($file) eq 'HASH' ? values(%$file):$file ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2019 | 37 | ▶ | die "$_ $f does not exist" if ! -f $f; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2020 | 37 | ▶ | die "$_ $f is not accessible" if ! -r _; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2021 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2022 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2023 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2024 | 30 | my $verify_mode = $arg_hash->{SSL_verify_mode}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2025 | 30 | ▶ | if ( $verify_mode != Net::SSLeay::VERIFY_NONE()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2026 | 0 | ▶ | if ( defined( my $f = $arg_hash->{SSL_ca_file} )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2027 | 0 | ▶ | if ( ! ref($f) || $$f ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not ref $f or $$f
MC/DC0%0/2
not ref $f or $$f
not ref $f
$$f
Truth table0%0/3
not(A) or B
A= not ref $fB= $$f
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2028 | 0 | ▶ | die "SSL_ca_file $f does not exist" if ! -f $f; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2029 | 0 | ▶ | die "SSL_ca_file $f is not accessible" if ! -r _; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2030 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2031 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2032 | 0 | ▶ | if ( defined( my $d = $arg_hash->{SSL_ca_path} )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2033 | 0 | ▶ | if ( ! ref($d) || $$d ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not ref $d or $$d
MC/DC0%0/2
not ref $d or $$d
not ref $d
$$d
Truth table0%0/3
not(A) or B
A= not ref $dB= $$d
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2034 | 0 | ▶ | die "SSL_ca_path $d does not exist" if ! -d $d; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2035 | 0 | ▶ | die "SSL_ca_path $d is not accessible" if ! -r _; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2036 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2037 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2038 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2039 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2040 | 30 | my $self = bless {},$class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2041 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2042 | 30 | my $vcn_scheme = delete $arg_hash->{SSL_verifycn_scheme}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2043 | 30 | my $vcn_publicsuffix = delete $arg_hash->{SSL_verifycn_publicsuffix}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2044 | 30 | ▶ | if ( ! $is_server and $verify_mode & 0x01 and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
not $is_server and $verify_mode & 1 and !$vcn_scheme || $vcn_scheme ne "none"
not $is_server and $verify_mode & 1
not $vcn_scheme or $vcn_scheme ne "none"
MC/DC0%0/4
not $is_server and $verify_mode & 1 and !$vcn_scheme || $vcn_scheme ne "none"
not $is_server
$verify_mode & 1
not $vcn_scheme
$vcn_scheme ne "none"
Truth table40%2/5
not(A) and B and not(C) or D
A= not $is_serverB= $verify_mode & 1C= not $vcn_schemeD= $vcn_scheme ne "none"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2045 | ! $vcn_scheme || $vcn_scheme ne 'none' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2046 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2047 | # gets updated during configure_SSL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2048 | 0 | my $verify_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2049 | 0 | $self->{verify_name_ref} = \$verify_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2050 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2051 | 0 | my $vcb = $arg_hash->{SSL_verify_callback}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2052 | $arg_hash->{SSL_verify_callback} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2053 | 0 | ▶ | my ($ok,$ctx_store,$certname,$error,$cert,$depth) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=14 SCAR=53.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2054 | 0 | ▶ | $ok = $vcb->($ok,$ctx_store,$certname,$error,$cert,$depth) if $vcb; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2055 | 0 | ▶ | $ok or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2056 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2057 | 0 | ▶ | return $ok if $depth != 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2058 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2059 | 0 | ▶ | my $host = $verify_name || ref($vcn_scheme) && $vcn_scheme->{callback} && 'unknown'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
$verify_name || ref $vcn_scheme && $vcn_scheme->{'callback'} && 'unknown'
ref $vcn_scheme and $vcn_scheme->{"callback"} and "unknown"
ref $vcn_scheme and $vcn_scheme->{"callback"}
MC/DC0%0/3
$verify_name || ref $vcn_scheme && $vcn_scheme->{'callback'} && 'unknown'
$verify_name
ref $vcn_scheme
$vcn_scheme->{"callback"}
Truth table0%0/4
A || B and C
A= $verify_nameB= ref $vcn_schemeC= $vcn_scheme->{"callback"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2060 | 0 | ▶ | if ( ! $host ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2061 | 0 | ▶ | if ( $vcn_scheme ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2062 | 0 | IO::Socket::SSL->_internal_error( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2063 | "Cannot determine peer hostname for verification" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2064 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2065 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2066 | 0 | warn "Cannot determine hostname of peer for verification. ". | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2067 | "Disabling default hostname verification for now. ". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2068 | "Please specify hostname with SSL_verifycn_name and better set SSL_verifycn_scheme too.\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2069 | 0 | return $ok; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2070 | ▶ | } elsif ( ! $vcn_scheme && $host =~m{^[\d.]+$|:} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
not $vcn_scheme and $host =~ /^[\d.]+$|:/
MC/DC0%0/2
not $vcn_scheme and $host =~ /^[\d.]+$|:/
not $vcn_scheme
$host =~ /^[\d.]+$|:/
Truth table0%0/3
not(A) and B
A= not $vcn_schemeB= $host =~ /^[\d.]+$|:/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2071 | # don't try to verify IP by default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2072 | 0 | return $ok; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2073 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2074 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2075 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2076 | # verify name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2077 | 0 | my $rv = IO::Socket::SSL::verify_hostname_of_cert( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2078 | $host,$cert,$vcn_scheme,$vcn_publicsuffix ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2079 | 0 | ▶ | if ( ! $rv && ! $vcn_scheme ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rv or $vcn_scheme
MC/DC0%0/2
$rv or $vcn_scheme
$rv
$vcn_scheme
Truth table0%0/3
A or B
A= $rvB= $vcn_scheme
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2080 | # For now we use the default hostname verification if none | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2081 | # was specified and complain loudly but return ok if it does | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2082 | # not match. In the future we will enforce checks and users | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2083 | # should better specify and explicite verification scheme. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2084 | 0 | warn <<WARN; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2085 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2086 | The verification of cert '$certname' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2087 | failed against the host '$host' with the default verification scheme. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2088 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2089 | THIS MIGHT BE A MAN-IN-THE-MIDDLE ATTACK !!!! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2090 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2091 | To stop this warning you might need to set SSL_verifycn_name to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2092 | the name of the host you expect in the certificate. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2093 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2094 | WARN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2095 | 0 | return $ok; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2096 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2097 | 0 | ▶ | if ( ! $rv ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2098 | 0 | IO::Socket::SSL->_internal_error( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2099 | "hostname verification failed" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2101 | 0 | return $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2102 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2105 | 30 | my $ssl_op = Net::SSLeay::OP_ALL(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2106 | 30 | $ssl_op |= &Net::SSLeay::OP_SINGLE_DH_USE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2107 | 30 | ▶ | $ssl_op |= &Net::SSLeay::OP_SINGLE_ECDH_USE if $can_ecdh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2109 | 30 | my $ver; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2110 | 30 | for (split(/\s*:\s*/,$arg_hash->{SSL_version})) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2111 | 82 | ▶ | m{^(!?)(?:(SSL(?:v2|v3|v23|v2/3))|(TLSv1(?:_?[12])?))$}i | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2112 | or croak("invalid SSL_version specified"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2113 | 82 | my $not = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2114 | 82 | ▶ | ( my $v = lc($2||$3) ) =~s{^(...)}{\U$1}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$2 || $3
MC/DC0%0/2
$2 || $3
$2
$3
Truth table66%2/3
A || B
A= $2B= $3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2115 | 82 | ▶ | if ( $not ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2116 | 52 | $ssl_op |= $SSL_OP_NO{$v}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2117 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2118 | 30 | ▶ | croak("cannot set multiple SSL protocols in SSL_version") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ver and $v ne $ver
MC/DC0%0/2
$ver and $v ne $ver
$ver
$v ne $ver
Truth table33%1/3
A and B
A= $verB= $v ne $ver
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2119 | if $ver && $v ne $ver; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2120 | 30 | $ver = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2121 | 30 | $ver =~s{/}{}; # interpret SSLv2/3 as SSLv23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2122 | 30 | $ver =~s{(TLSv1)(\d)}{$1\_$2}; # TLSv1_1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2126 | 30 | ▶ | my $ctx_new_sub = UNIVERSAL::can( 'Net::SSLeay', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2127 | $ver eq 'SSLv2' ? 'CTX_v2_new' : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2128 | $ver eq 'SSLv3' ? 'CTX_v3_new' : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2129 | $ver eq 'TLSv1' ? 'CTX_tlsv1_new' : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2130 | $ver eq 'TLSv1_1' ? 'CTX_tlsv1_1_new' : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2131 | $ver eq 'TLSv1_2' ? 'CTX_tlsv1_2_new' : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2132 | 'CTX_new' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2133 | ) or return IO::Socket::SSL->_internal_error("SSL Version $ver not supported"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2135 | # For SNI in server mode we need a separate context for each certificate. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2136 | 30 | my %ctx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2137 | 30 | ▶ | if ($arg_hash->{'SSL_server'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2138 | 20 | my %sni; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2139 | 20 | for my $opt (qw(SSL_key SSL_key_file SSL_cert SSL_cert_file)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2140 | 80 | ▶ | my $val = $arg_hash->{$opt} or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2141 | 35 | ▶ | if ( ref($val) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2142 | 0 | ▶ | while ( my ($host,$v) = each %$val ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2143 | 0 | $sni{lc($host)}{$opt} = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2147 | 20 | ▶ | while (my ($host,$v) = each %sni) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2148 | 0 | $ctx{$host} = { %$arg_hash, %$v }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2151 | 30 | ▶ | $ctx{''} = $arg_hash if ! %ctx; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2153 | 30 | ▶ | while (my ($host,$arg_hash) = each %ctx) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2154 | # replace value in %ctx with real context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2155 | 30 | ▶ | my $ctx = $ctx_new_sub->() or return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2156 | IO::Socket::SSL->error("SSL Context init failed"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2157 | 30 | $CTX_CREATED_IN_THIS_THREAD{$ctx} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2159 | # SSL_OP_CIPHER_SERVER_PREFERENCE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2160 | 30 | ▶ | $ssl_op |= 0x00400000 if $arg_hash->{SSL_honor_cipher_order}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2162 | 30 | ▶ | if ($ver eq 'SSLv23' && !($ssl_op & $SSL_OP_NO{SSLv3})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$ver eq "SSLv23" and not $ssl_op & $SSL_OP_NO{"SSLv3"}
MC/DC100%2/2
$ver eq "SSLv23" and not $ssl_op & $SSL_OP_NO{"SSLv3"}
$ver eq "SSLv23"
not $ssl_op & $SSL_OP_NO{"SSLv3"}
Truth table100%3/3
A and not(B)
A= $ver eq "SSLv23"B= not $ssl_op & $SSL_OP_NO{"SSLv3"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2163 | # At least LibreSSL disables SSLv3 by default in SSL_CTX_new. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2164 | # If we really want SSL3.0 we need to explicitly allow it with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2165 | # SSL_CTX_clear_options. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2166 | 1 | Net::SSLeay::CTX_clear_options($ctx,$SSL_OP_NO{SSLv3}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2169 | 30 | Net::SSLeay::CTX_set_options($ctx,$ssl_op); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2171 | # if we don't set session_id_context if client certificate is expected | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2172 | # client session caching will fail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2173 | # if user does not provide explicit id just use the stringification | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2174 | # of the context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2175 | 30 | ▶ | if ( my $id = $arg_hash->{SSL_session_id_context} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$arg_hash->{'SSL_session_id_context'} || $arg_hash->{'SSL_verify_mode'} & 1 && "$ctx"
$arg_hash->{"SSL_verify_mode"} & 1 and "$ctx"
MC/DC0%0/3
$arg_hash->{'SSL_session_id_context'} || $arg_hash->{'SSL_verify_mode'} & 1 && "$ctx"
$arg_hash->{'SSL_session_id_context'}
$arg_hash->{"SSL_verify_mode"} & 1
"$ctx"
Truth table25%1/4
A || B and C
A= $arg_hash->{'SSL_session_id_context'}B= $arg_hash->{"SSL_verify_mode"} & 1C= "$ctx"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2176 | || ( $arg_hash->{SSL_verify_mode} & 0x01 ) && "$ctx" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2177 | 0 | Net::SSLeay::CTX_set_session_id_context($ctx,$id,length($id)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2180 | # SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER makes syswrite return if at least one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2181 | # buffer was written and not block for the rest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2182 | # SSL_MODE_ENABLE_PARTIAL_WRITE can be necessary for non-blocking because we | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2183 | # cannot guarantee, that the location of the buffer stays constant | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2184 | 30 | Net::SSLeay::CTX_set_mode( $ctx, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2185 | SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER|SSL_MODE_ENABLE_PARTIAL_WRITE); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2187 | 30 | ▶ | if ( my $proto_list = $arg_hash->{SSL_npn_protocols} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2188 | 1 | ▶ | return IO::Socket::SSL->_internal_error("NPN not supported in Net::SSLeay") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2189 | if ! $can_npn; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2190 | 1 | ▶ | if($arg_hash->{SSL_server}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2191 | # on server side SSL_npn_protocols means a list of advertised protocols | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2192 | 1 | Net::SSLeay::CTX_set_next_protos_advertised_cb($ctx, $proto_list); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2193 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2194 | # on client side SSL_npn_protocols means a list of preferred protocols | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2195 | # negotiation algorithm used is "as-openssl-implements-it" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2196 | 0 | Net::SSLeay::CTX_set_next_proto_select_cb($ctx, $proto_list); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2200 | # Try to apply SSL_ca even if SSL_verify_mode is 0, so that they can be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2201 | # used to verify OCSP responses. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2202 | # If applying fails complain only if verify_mode != VERIFY_NONE. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2203 | 30 | ▶ | if ( $arg_hash->{SSL_ca} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%4/6
$arg_hash->{"SSL_ca"} or defined $arg_hash->{"SSL_ca_file"} or defined $arg_hash->{"SSL_ca_path"}
$arg_hash->{"SSL_ca"} or defined $arg_hash->{"SSL_ca_file"}
MC/DC33%1/3
$arg_hash->{"SSL_ca"} or defined $arg_hash->{"SSL_ca_file"} or defined $arg_hash->{"SSL_ca_path"}
$arg_hash->{"SSL_ca"}
defined $arg_hash->{"SSL_ca_file"}
defined $arg_hash->{"SSL_ca_path"}
Truth table50%2/4
A or B or C
A= $arg_hash->{"SSL_ca"}B= defined $arg_hash->{"SSL_ca_file"}C= defined $arg_hash->{"SSL_ca_path"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2204 | || defined $arg_hash->{SSL_ca_file} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2205 | || defined $arg_hash->{SSL_ca_path} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2206 | 8 | my $file = $arg_hash->{SSL_ca_file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2207 | 8 | ▶ | $file = undef if ref($file) && ! $$file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $file and not $$file
MC/DC0%0/2
ref $file and not $$file
ref $file
not $$file
Truth table33%1/3
A and not(B)
A= ref $fileB= not $$file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2208 | 8 | my $dir = $arg_hash->{SSL_ca_path}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2209 | 8 | ▶ | $dir = undef if ref($dir) && ! $$dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $dir and not $$dir
MC/DC0%0/2
ref $dir and not $$dir
ref $dir
not $$dir
Truth table33%1/3
A and not(B)
A= ref $dirB= not $$dir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2210 | 8 | ▶ | if ( $arg_hash->{SSL_ca} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2211 | 0 | my $store = Net::SSLeay::CTX_get_cert_store($ctx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2212 | 0 | for (@{$arg_hash->{SSL_ca}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2213 | 0 | ▶ | Net::SSLeay::X509_STORE_add_cert($store,$_) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2214 | return IO::Socket::SSL->error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2215 | "Failed to add certificate to CA store"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2218 | 8 | ▶ | if ( $file || $dir and ! Net::SSLeay::CTX_load_verify_locations( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%4/10
$file || $dir and not &Net::SSLeay::CTX_load_verify_locations($ctx, scalar($file || ""), scalar($dir || ""))
$file or $dir
$file || ''
$dir || ''
MC/DC0%0/3
$file || $dir and not &Net::SSLeay::CTX_load_verify_locations($ctx, scalar($file || ""), scalar($dir || ""))
$file
$dir
not &Net::SSLeay::CTX_load_verify_locations($ctx, scalar($file || ""), scalar($dir || ""))
MC/DC0%0/1
$file || ''
$file
MC/DC0%0/1
$dir || ''
$dir
Truth table20%1/5
A or B and not(C)
A= $fileB= $dirC= not &Net::SSLeay::CTX_load_verify_locations($ctx, scalar($file || ""), scalar($dir || ""))
Truth table50%1/2
A
A= $file
Truth table50%1/2
A
A= $dir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2219 | $ctx, $file || '', $dir || '')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2220 | 0 | ▶ | return IO::Socket::SSL->error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2221 | "Invalid certificate authority locations") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2222 | if $verify_mode != Net::SSLeay::VERIFY_NONE(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2224 | } elsif ( my %ca = IO::Socket::SSL::default_ca()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2225 | # no CA path given, continue with system defaults | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2226 | 22 | ▶ | if (! Net::SSLeay::CTX_load_verify_locations( $ctx, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition42%3/7
not &Net::SSLeay::CTX_load_verify_locations($ctx, scalar($ca{"SSL_ca_file"} || ""), scalar($ca{"SSL_ca_path"} || "")) and $verify_mode != Net::SSLeay::VERIFY_NONE()
$ca{'SSL_ca_file'} || ''
$ca{'SSL_ca_path'} || ''
MC/DC0%0/2
not &Net::SSLeay::CTX_load_verify_locations($ctx, scalar($ca{"SSL_ca_file"} || ""), scalar($ca{"SSL_ca_path"} || "")) and $verify_mode != Net::SSLeay::VERIFY_NONE()
not &Net::SSLeay::CTX_load_verify_locations($ctx, scalar($ca{"SSL_ca_file"} || ""), scalar($ca{"SSL_ca_path"} || ""))
$verify_mode != Net::SSLeay::VERIFY_NONE()
MC/DC0%0/1
$ca{'SSL_ca_file'} || ''
$ca{'SSL_ca_file'}
MC/DC0%0/1
$ca{'SSL_ca_path'} || ''
$ca{'SSL_ca_path'}
Truth table33%1/3
not(A) and B
A= not &Net::SSLeay::CTX_load_verify_locations($ctx, scalar($ca{"SSL_ca_file"} || ""), scalar($ca{"SSL_ca_path"} || ""))B= $verify_mode != Net::SSLeay::VERIFY_NONE()
Truth table50%1/2
A
A= $ca{'SSL_ca_file'}
Truth table50%1/2
A
A= $ca{'SSL_ca_path'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2227 | $ca{SSL_ca_file} || '',$ca{SSL_ca_path} || '') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2228 | && $verify_mode != Net::SSLeay::VERIFY_NONE()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2229 | 0 | return IO::Socket::SSL->error( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2230 | "Invalid default certificate authority locations") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2234 | 30 | ▶ | if ($arg_hash->{'SSL_check_crl'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2235 | 0 | Net::SSLeay::X509_STORE_set_flags( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2236 | Net::SSLeay::CTX_get_cert_store($ctx), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2237 | Net::SSLeay::X509_V_FLAG_CRL_CHECK() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2238 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2239 | 0 | ▶ | if ($arg_hash->{'SSL_crl_file'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2240 | 0 | my $bio = Net::SSLeay::BIO_new_file($arg_hash->{'SSL_crl_file'}, 'r'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2241 | 0 | my $crl = Net::SSLeay::PEM_read_bio_X509_CRL($bio); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2242 | 0 | ▶ | if ( $crl ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2243 | 0 | Net::SSLeay::X509_STORE_add_crl(Net::SSLeay::CTX_get_cert_store($ctx), $crl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2244 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2245 | 0 | return IO::Socket::SSL->error("Invalid certificate revocation list"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2250 | Net::SSLeay::CTX_set_default_passwd_cb($ctx,$arg_hash->{SSL_passwd_cb}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2251 | 30 | ▶ | if $arg_hash->{SSL_passwd_cb}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2253 | 30 | my ($havekey,$havecert); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2254 | 30 | ▶ | if ( my $x509 = $arg_hash->{SSL_cert} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2255 | # binary, e.g. X509* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2256 | # we have either a single certificate or a list with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2257 | # a chain of certificates | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2258 | 0 | ▶ | my @x509 = ref($x509) eq 'ARRAY' ? @$x509: ($x509); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2259 | 0 | my $cert = shift @x509; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2260 | 0 | ▶ | Net::SSLeay::CTX_use_certificate( $ctx,$cert ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2261 | || return IO::Socket::SSL->error("Failed to use Certificate"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2262 | 0 | foreach my $ca (@x509) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2263 | 0 | ▶ | Net::SSLeay::CTX_add_extra_chain_cert( $ctx,$ca ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2264 | || return IO::Socket::SSL->error("Failed to use Certificate"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2266 | 0 | $havecert = 'OBJ'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2267 | } elsif ( my $f = $arg_hash->{SSL_cert_file} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2268 | # try to load chain from PEM or certificate from ASN1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2269 | 16 | ▶ | if (Net::SSLeay::CTX_use_certificate_chain_file($ctx,$f)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2270 | 0 | $havecert = 'PEM'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2271 | } elsif (Net::SSLeay::CTX_use_certificate_file($ctx,$f,FILETYPE_ASN1)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2272 | 0 | $havecert = 'DER'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2273 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2274 | # try to load certificate, key and chain from PKCS12 file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2275 | 16 | my ($key,$cert,@chain) = Net::SSLeay::P_PKCS12_load_file($f,1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2276 | 16 | ▶ | if (!$cert and $arg_hash->{SSL_passwd_cb} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
not $cert and $arg_hash->{"SSL_passwd_cb"} and defined(my $pw = $arg_hash->{"SSL_passwd_cb"}->(0))
not $cert and $arg_hash->{"SSL_passwd_cb"}
MC/DC33%1/3
not $cert and $arg_hash->{"SSL_passwd_cb"} and defined(my $pw = $arg_hash->{"SSL_passwd_cb"}->(0))
not $cert
$arg_hash->{"SSL_passwd_cb"}
defined(my $pw = $arg_hash->{"SSL_passwd_cb"}->(0))
Truth table50%2/4
not(A) and B and C
A= not $certB= $arg_hash->{"SSL_passwd_cb"}C= defined(my $pw = $arg_hash->{"SSL_passwd_cb"}->(0))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2277 | and defined( my $pw = $arg_hash->{SSL_passwd_cb}->(0))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2278 | 2 | ($key,$cert,@chain) = Net::SSLeay::P_PKCS12_load_file($f,1,$pw); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2280 | 16 | ▶ | PKCS12: while ($cert) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2281 | 0 | ▶ | Net::SSLeay::CTX_use_certificate($ctx,$cert) or last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2282 | 0 | for my $ca (@chain) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2283 | 0 | ▶ | Net::SSLeay::CTX_add_extra_chain_cert($ctx,$ca) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2284 | or last PKCS12; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2286 | 0 | ▶ | last if $key && ! Net::SSLeay::CTX_use_PrivateKey($ctx,$key); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$key and not &Net::SSLeay::CTX_use_PrivateKey($ctx, $key)
MC/DC0%0/2
$key and not &Net::SSLeay::CTX_use_PrivateKey($ctx, $key)
$key
not &Net::SSLeay::CTX_use_PrivateKey($ctx, $key)
Truth table0%0/3
A and not(B)
A= $keyB= not &Net::SSLeay::CTX_use_PrivateKey($ctx, $key)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2287 | 0 | $havecert = 'PKCS12'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2288 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2290 | 16 | ▶ | $havekey = 'PKCS12' if $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2291 | 16 | ▶ | Net::SSLeay::X509_free($cert) if $cert; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2292 | 16 | ▶ | Net::SSLeay::EVP_PKEY_free($key) if $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2293 | # don't free @chain, because CTX_add_extra_chain_cert | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2294 | # did not duplicate the certificates | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2296 | 16 | ▶ | $havecert or return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2297 | IO::Socket::SSL->error("Failed to use certificate file"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2300 | 14 | ▶ | if (!$havecert || $havekey) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition33%1/3
not $havecert or $havekey
MC/DC0%0/2
not $havecert or $havekey
not $havecert
$havekey
Truth table33%1/3
not(A) or B
A= not $havecertB= $havekey
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2301 | # skip SSL_key_* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2302 | } elsif ( my $pkey = $arg_hash->{SSL_key} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2303 | # binary, e.g. EVP_PKEY* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2304 | 0 | ▶ | Net::SSLeay::CTX_use_PrivateKey($ctx, $pkey) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2305 | || return IO::Socket::SSL->error("Failed to use Private Key"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2306 | 0 | $havekey = 'MEM'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2307 | ▶ | } elsif ( my $f = $arg_hash->{SSL_key_file} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$arg_hash->{'SSL_key_file'} || ($havecert eq 'PEM' ? $arg_hash->{'SSL_cert_file'} : undef)
MC/DC0%0/2
$arg_hash->{'SSL_key_file'} || ($havecert eq 'PEM' ? $arg_hash->{'SSL_cert_file'} : undef)
$arg_hash->{'SSL_key_file'}
($havecert eq 'PEM' ? $arg_hash->{'SSL_cert_file'} : undef)
Truth table0%0/3
A || B
A= $arg_hash->{'SSL_key_file'}B= ($havecert eq 'PEM' ? $arg_hash->{'SSL_cert_file'} : undef)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2308 | || (($havecert eq 'PEM') ? $arg_hash->{SSL_cert_file}:undef) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2309 | 0 | for my $ft ( FILETYPE_PEM, FILETYPE_ASN1 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2310 | 0 | ▶ | if (Net::SSLeay::CTX_use_PrivateKey_file($ctx,$f,$ft)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2311 | 0 | ▶ | $havekey = ($ft == FILETYPE_PEM) ? 'PEM':'DER'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2312 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2316 | 14 | ▶ | if ($havecert && !$havekey) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$havecert and not $havekey
MC/DC0%0/2
$havecert and not $havekey
$havecert
not $havekey
Truth table33%1/3
A and not(B)
A= $havecertB= not $havekey
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2317 | 0 | return IO::Socket::SSL->error("Failed to use private key"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2320 | # replace arg_hash with created context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2321 | 14 | $ctx{$host} = $ctx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2324 | 14 | ▶ | if ($arg_hash->{'SSL_server'} || $arg_hash->{'SSL_use_cert'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$arg_hash->{"SSL_server"} or $arg_hash->{"SSL_use_cert"}
MC/DC50%1/2
$arg_hash->{"SSL_server"} or $arg_hash->{"SSL_use_cert"}
$arg_hash->{"SSL_server"}
$arg_hash->{"SSL_use_cert"}
Truth table66%2/3
A or B
A= $arg_hash->{"SSL_server"}B= $arg_hash->{"SSL_use_cert"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2326 | 4 | ▶ | if ( my $f = $arg_hash->{SSL_dh_file} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2327 | 0 | ▶ | my $bio = Net::SSLeay::BIO_new_file( $f,'r' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
&Net::SSLeay::BIO_new_file($f, 'r') || (return 'IO::Socket::SSL'->error("Failed to open DH file $f"))
MC/DC0%0/1
&Net::SSLeay::BIO_new_file($f, 'r') || (return 'IO::Socket::SSL'->error("Failed to open DH file $f"))
&Net::SSLeay::BIO_new_file($f, 'r')
Truth table0%0/2
A
A= &Net::SSLeay::BIO_new_file($f, 'r')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2328 | || return IO::Socket::SSL->error( "Failed to open DH file $f" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2329 | 0 | my $dh = Net::SSLeay::PEM_read_bio_DHparams($bio); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2330 | 0 | Net::SSLeay::BIO_free($bio); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2331 | 0 | ▶ | $dh || return IO::Socket::SSL->error( "Failed to read PEM for DH from $f - wrong format?" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2332 | 0 | my $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2333 | 0 | for (values (%ctx)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2334 | 0 | ▶ | $rv = Net::SSLeay::CTX_set_tmp_dh( $_,$dh ) or last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2336 | 0 | Net::SSLeay::DH_free( $dh ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2337 | 0 | ▶ | $rv || return IO::Socket::SSL->error( "Failed to set DH from $f" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2338 | } elsif ( my $dh = $arg_hash->{SSL_dh} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2339 | # binary, e.g. DH* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2341 | 4 | for( values %ctx ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2342 | 4 | ▶ | Net::SSLeay::CTX_set_tmp_dh( $_,$dh ) || return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2343 | IO::Socket::SSL->error( "Failed to set DH from SSL_dh" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2347 | 4 | ▶ | if ( my $curve = $arg_hash->{SSL_ecdh_curve} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2348 | 4 | ▶ | return IO::Socket::SSL->_internal_error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2349 | "ECDH curve needs Net::SSLeay>=1.56 and OpenSSL>=1.0") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2350 | if ! $can_ecdh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2351 | 4 | ▶ | if ( $curve !~ /^\d+$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2352 | # name of curve, find NID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2353 | 4 | ▶ | $curve = Net::SSLeay::OBJ_txt2nid($curve) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
&Net::SSLeay::OBJ_txt2nid($curve) || (return 'IO::Socket::SSL'->error("cannot find NID for curve name '${curve}'"))
MC/DC0%0/1
&Net::SSLeay::OBJ_txt2nid($curve) || (return 'IO::Socket::SSL'->error("cannot find NID for curve name '${curve}'"))
&Net::SSLeay::OBJ_txt2nid($curve)
Truth table50%1/2
A
A= &Net::SSLeay::OBJ_txt2nid($curve)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2354 | || return IO::Socket::SSL->error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2355 | "cannot find NID for curve name '$curve'"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2357 | 4 | ▶ | my $ecdh = Net::SSLeay::EC_KEY_new_by_curve_name($curve) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2358 | return IO::Socket::SSL->error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2359 | "cannot create curve for NID $curve"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2360 | 4 | for( values %ctx ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2361 | 4 | ▶ | Net::SSLeay::CTX_set_tmp_ecdh($_,$ecdh) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2362 | return IO::Socket::SSL->error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2363 | "failed to set ECDH curve context"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2365 | 4 | Net::SSLeay::EC_KEY_free($ecdh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2369 | 14 | my $verify_cb = $arg_hash->{SSL_verify_callback}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2370 | 14 | my @accept_fp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2371 | 14 | ▶ | if ( my $fp = $arg_hash->{SSL_fingerprint} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2372 | 0 | ▶ | for( ref($fp) ? @$fp : $fp) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2373 | 0 | my ($algo,$digest) = m{^([\w-]+)\$([a-f\d:]+)$}i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2374 | 0 | ▶ | return IO::Socket::SSL->_internal_error("invalid fingerprint '$_'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2375 | if ! $algo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2376 | 0 | $algo = lc($algo); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2377 | 0 | ( $digest = lc($digest) ) =~s{:}{}g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2378 | 0 | push @accept_fp,[ $algo, pack('H*',$digest) ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2381 | 14 | ▶ | my $verify_fingerprint = @accept_fp && do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
@accept_fp && do {
my $fail;
sub {
my($ok, $cert, $depth) = @_;
$fail = 1 unless $ok;
return 1 if $depth > 0;
my %fp;
foreach $_ (@accept_fp) {
my $fp = ($fp{$_->[0]} ||= &Net::SSLeay::X509_digest($cert, scalar &$algo2digest($_->[0])));
next if $fp ne $_->[1];
return 1;
};
return !$fail;
}
}
MC/DC0%0/2
@accept_fp && do {
my $fail;
sub {
my($ok, $cert, $depth) = @_;
$fail = 1 unless $ok;
return 1 if $depth > 0;
my %fp;
foreach $_ (@accept_fp) {
my $fp = ($fp{$_->[0]} ||= &Net::SSLeay::X509_digest($cert, scalar &$algo2digest($_->[0])));
next if $fp ne $_->[1];
return 1;
};
return !$fail;
}
}
@accept_fp
do {
my $fail;
sub {
my($ok, $cert, $depth) = @_;
$fail = 1 unless $ok;
return 1 if $depth > 0;
my %fp;
foreach $_ (@accept_fp) {
my $fp = ($fp{$_->[0]} ||= &Net::SSLeay::X509_digest($cert, scalar &$algo2digest($_->[0])));
next if $fp ne $_->[1];
return 1;
};
return !$fail;
}
}
Truth table33%1/3
A && B
A= @accept_fpB= do {
my $fail;
sub {
my($ok, $cert, $depth) = @_;
$fail = 1 unless $ok;
return 1 if $depth > 0;
my %fp;
foreach $_ (@accept_fp) {
my $fp = ($fp{$_->[0]} ||= &Net::SSLeay::X509_digest($cert, scalar &$algo2digest($_->[0])));
next if $fp ne $_->[1];
return 1;
};
return !$fail;
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2382 | 0 | my $fail; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2383 | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2384 | 0 | ▶ | my ($ok,$cert,$depth) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2385 | 0 | ▶ | $fail = 1 if ! $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2386 | 0 | ▶ | return 1 if $depth>0; # to let us continue with verification | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2387 | # Check fingerprint only from top certificate. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2388 | 0 | my %fp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2389 | 0 | for(@accept_fp) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2390 | 0 | ▶ | my $fp = $fp{$_->[0]} ||= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$fp{$_->[0]} ||= &Net::SSLeay::X509_digest($cert, scalar &$algo2digest($_->[0]))
MC/DC0%0/2
$fp{$_->[0]} ||= &Net::SSLeay::X509_digest($cert, scalar &$algo2digest($_->[0]))
$fp{$_->[0]}
&Net::SSLeay::X509_digest($cert, scalar &$algo2digest($_->[0]))
Truth table0%0/3
A ||= B
A= $fp{$_->[0]}B= &Net::SSLeay::X509_digest($cert, scalar &$algo2digest($_->[0]))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2391 | Net::SSLeay::X509_digest($cert,$algo2digest->($_->[0])); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2392 | 0 | ▶ | next if $fp ne $_->[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2393 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2395 | 0 | return ! $fail; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2397 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2398 | my $verify_callback = ( $verify_cb || @accept_fp ) && sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2399 | 0 | ▶ | my ($ok, $ctx_store) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2400 | 0 | my ($certname,$cert,$error,$depth); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2401 | 0 | ▶ | if ($ctx_store) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2402 | 0 | $cert = Net::SSLeay::X509_STORE_CTX_get_current_cert($ctx_store); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2403 | 0 | $error = Net::SSLeay::X509_STORE_CTX_get_error($ctx_store); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2404 | 0 | $depth = Net::SSLeay::X509_STORE_CTX_get_error_depth($ctx_store); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2405 | 0 | $certname = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2406 | Net::SSLeay::X509_NAME_oneline(Net::SSLeay::X509_get_issuer_name($cert)). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2407 | Net::SSLeay::X509_NAME_oneline(Net::SSLeay::X509_get_subject_name($cert)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2408 | 0 | ▶ | $error &&= Net::SSLeay::ERR_error_string($error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$error &&= &Net::SSLeay::ERR_error_string($error)
MC/DC0%0/2
$error &&= &Net::SSLeay::ERR_error_string($error)
$error
&Net::SSLeay::ERR_error_string($error)
Truth table0%0/3
A &&= B
A= $errorB= &Net::SSLeay::ERR_error_string($error)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2409 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2410 | 0 | ▶ | $DEBUG>=3 && DEBUG( "ok=$ok cert=$cert" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2411 | 0 | ▶ | $ok = $verify_cb->($ok,$ctx_store,$certname,$error,$cert,$depth) if $verify_cb; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2412 | 0 | ▶ | $ok = $verify_fingerprint->($ok,$cert,$depth) if $verify_fingerprint && $cert; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$verify_fingerprint and $cert
MC/DC0%0/2
$verify_fingerprint and $cert
$verify_fingerprint
$cert
Truth table0%0/3
A and B
A= $verify_fingerprintB= $cert
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2413 | 0 | return $ok; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2414 | 14 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
($verify_cb || @accept_fp) && sub {
my($ok, $ctx_store) = @_;
my($certname, $cert, $error, $depth);
if ($ctx_store) {
$cert = &Net::SSLeay::X509_STORE_CTX_get_current_cert($ctx_store);
$error = &Net::SSLeay::X509_STORE_CTX_get_error($ctx_store);
$depth = &Net::SSLeay::X509_STORE_CTX_get_error_depth($ctx_store);
$certname = &Net::SSLeay::X509_NAME_oneline(scalar &Net::SSLeay::X509_get_issuer_name($cert)) . &Net::SSLeay::X509_NAME_oneline(scalar &Net::SSLeay::X509_get_subject_name($cert));
$error &&= &Net::SSLeay::ERR_error_string($error);
};
$IO::Socket::SSL::DEBUG >= 3 and DEBUG("ok=$ok cert=$cert");
$ok = &$verify_cb($ok, $ctx_store, $certname, $error, $cert, $depth) if $verify_cb;
$ok = &$verify_fingerprint($ok, $cert, $depth) if $verify_fingerprint and $cert;
return $ok;
}
$verify_cb or @accept_fp
MC/DC0%0/3
($verify_cb || @accept_fp) && sub {
my($ok, $ctx_store) = @_;
my($certname, $cert, $error, $depth);
if ($ctx_store) {
$cert = &Net::SSLeay::X509_STORE_CTX_get_current_cert($ctx_store);
$error = &Net::SSLeay::X509_STORE_CTX_get_error($ctx_store);
$depth = &Net::SSLeay::X509_STORE_CTX_get_error_depth($ctx_store);
$certname = &Net::SSLeay::X509_NAME_oneline(scalar &Net::SSLeay::X509_get_issuer_name($cert)) . &Net::SSLeay::X509_NAME_oneline(scalar &Net::SSLeay::X509_get_subject_name($cert));
$error &&= &Net::SSLeay::ERR_error_string($error);
};
$IO::Socket::SSL::DEBUG >= 3 and DEBUG("ok=$ok cert=$cert");
$ok = &$verify_cb($ok, $ctx_store, $certname, $error, $cert, $depth) if $verify_cb;
$ok = &$verify_fingerprint($ok, $cert, $depth) if $verify_fingerprint and $cert;
return $ok;
}
$verify_cb
@accept_fp
sub {
my($ok, $ctx_store) = @_;
my($certname, $cert, $error, $depth);
if ($ctx_store) {
$cert = &Net::SSLeay::X509_STORE_CTX_get_current_cert($ctx_store);
$error = &Net::SSLeay::X509_STORE_CTX_get_error($ctx_store);
$depth = &Net::SSLeay::X509_STORE_CTX_get_error_depth($ctx_store);
$certname = &Net::SSLeay::X509_NAME_oneline(scalar &Net::SSLeay::X509_get_issuer_name($cert)) . &Net::SSLeay::X509_NAME_oneline(scalar &Net::SSLeay::X509_get_subject_name($cert));
$error &&= &Net::SSLeay::ERR_error_string($error);
};
$IO::Socket::SSL::DEBUG >= 3 and DEBUG("ok=$ok cert=$cert");
$ok = &$verify_cb($ok, $ctx_store, $certname, $error, $cert, $depth) if $verify_cb;
$ok = &$verify_fingerprint($ok, $cert, $depth) if $verify_fingerprint and $cert;
return $ok;
}
Truth table20%1/5
A or B && C
A= $verify_cbB= @accept_fpC= sub {
my($ok, $ctx_store) = @_;
my($certname, $cert, $error, $depth);
if ($ctx_store) {
$cert = &Net::SSLeay::X509_STORE_CTX_get_current_cert($ctx_store);
$error = &Net::SSLeay::X509_STORE_CTX_get_error($ctx_store);
$depth = &Net::SSLeay::X509_STORE_CTX_get_error_depth($ctx_store);
$certname = &Net::SSLeay::X509_NAME_oneline(scalar &Net::SSLeay::X509_get_issuer_name($cert)) . &Net::SSLeay::X509_NAME_oneline(scalar &Net::SSLeay::X509_get_subject_name($cert));
$error &&= &Net::SSLeay::ERR_error_string($error);
};
$IO::Socket::SSL::DEBUG >= 3 and DEBUG("ok=$ok cert=$cert");
$ok = &$verify_cb($ok, $ctx_store, $certname, $error, $cert, $depth) if $verify_cb;
$ok = &$verify_fingerprint($ok, $cert, $depth) if $verify_fingerprint and $cert;
return $ok;
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2416 | 14 | ▶ | if ( $^O eq 'darwin' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2417 | # explicitely set error code to disable use of apples TEA patch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2418 | # https://hynek.me/articles/apple-openssl-verification-surprises/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2419 | 0 | my $vcb = $verify_callback; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2420 | $verify_callback = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2421 | 0 | ▶ | my $rv = $vcb ? &$vcb : $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2422 | 0 | ▶ | if ( $rv != 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2423 | # 50 - X509_V_ERR_APPLICATION_VERIFICATION: application verification failure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2424 | 0 | Net::SSLeay::X509_STORE_CTX_set_error($_[1], 50); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2426 | 0 | return $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2427 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2429 | Net::SSLeay::CTX_set_verify($_, $verify_mode, $verify_callback) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2430 | 14 | for (values %ctx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2432 | 14 | my $staple_callback = $arg_hash->{SSL_ocsp_staple_callback}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2433 | 14 | ▶ | if ( !$is_server && $can_ocsp_staple ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $is_server and $can_ocsp_staple
MC/DC50%1/2
not $is_server and $can_ocsp_staple
not $is_server
$can_ocsp_staple
Truth table66%2/3
not(A) and B
A= not $is_serverB= $can_ocsp_staple
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2434 | 10 | $self->{ocsp_cache} = $arg_hash->{SSL_ocsp_cache}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2435 | my $status_cb = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2436 | 0 | ▶ | my ($ssl,$resp) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=24 SCAR=64.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2437 | 0 | ▶ | my $iossl = $SSL_OBJECT{$ssl} or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2438 | die "no IO::Socket::SSL object found for SSL $ssl"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2439 | 0 | ▶ | $iossl->[1] and do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2440 | # we must return with 1 or it will be called again | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2441 | # and beause we have no SSL object we must make the error global | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2442 | 0 | Carp::cluck($IO::Socket::SSL::SSL_ERROR | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2443 | = "OCSP callback on server side"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2444 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2445 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2446 | 0 | $iossl = $iossl->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2448 | # if we have a callback use this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2449 | # callback must not free or copy $resp !! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2450 | 0 | ▶ | if ( $staple_callback ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2451 | 0 | $staple_callback->($iossl,$resp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2452 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2453 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2455 | # default callback does verification | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2456 | 0 | ▶ | if ( ! $resp ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2457 | 0 | ▶ | $DEBUG>=3 && DEBUG("did not get stapled OCSP response"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2458 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2460 | 0 | ▶ | $DEBUG>=3 && DEBUG("got stapled OCSP response"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2461 | 0 | my $status = Net::SSLeay::OCSP_response_status($resp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2462 | 0 | ▶ | if ($status != Net::SSLeay::OCSP_RESPONSE_STATUS_SUCCESSFUL()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2463 | 0 | ▶ | $DEBUG>=3 && DEBUG("bad status of stapled OCSP response: ". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2464 | Net::SSLeay::OCSP_response_status_str($status)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2465 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2467 | 0 | ▶ | if (!eval { Net::SSLeay::OCSP_response_verify($ssl,$resp) }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2468 | 0 | ▶ | $DEBUG>=3 && DEBUG("verify of stapled OCSP response failed"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2469 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2470 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2471 | 0 | my (@results,$hard_error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2472 | 0 | my @chain = $iossl->peer_certificates; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2473 | 0 | for my $cert (@chain) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2474 | 0 | my $certid = eval { Net::SSLeay::OCSP_cert2ids($ssl,$cert) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2475 | 0 | ▶ | if (!$certid) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2476 | 0 | ▶ | $DEBUG>=3 && DEBUG("cannot create OCSP_CERTID: $@"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2477 | 0 | push @results,[-1,$@]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2478 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2479 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2480 | 0 | ($status) = Net::SSLeay::OCSP_response_results($resp,$certid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2481 | 0 | ▶ | if ($status && $status->[2]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$status and $status->[2]
MC/DC0%0/2
$status and $status->[2]
$status
$status->[2]
Truth table0%0/3
A and B
A= $statusB= $status->[2]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2482 | 0 | my $cache = ${*$iossl}{_SSL_ctx}{ocsp_cache}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2483 | 0 | ▶ | if (!$status->[1]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2484 | 0 | push @results,[1,$status->[2]{nextUpdate}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2485 | 0 | ▶ | $cache && $cache->put($certid,$status->[2]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2486 | } elsif ( $status->[2]{statusType} == | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2487 | Net::SSLeay::V_OCSP_CERTSTATUS_GOOD()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2488 | 0 | push @results,[1,$status->[2]{nextUpdate}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2489 | $cache && $cache->put($certid,{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2490 | 0 | ▶ | %{$status->[2]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2491 | expire => time()+120, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2492 | soft_error => $status->[1], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2493 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2494 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2495 | 0 | push @results,($hard_error = [0,$status->[1]]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2496 | $cache && $cache->put($certid,{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2497 | 0 | ▶ | %{$status->[2]}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2498 | hard_error => $status->[1], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2499 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2500 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2502 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2503 | # return result of lead certificate, this should be in chain[0] and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2504 | # thus result[0], but we better check. But if we had any hard_error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2505 | # return this instead | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2506 | 0 | ▶ | if ($hard_error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2507 | 0 | ${*$iossl}{_SSL_ocsp_verify} = $hard_error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2508 | ▶ | } elsif (@results and $chain[0] == $iossl->peer_certificate) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
@results and $chain[0] == $iossl->peer_certificate
MC/DC0%0/2
@results and $chain[0] == $iossl->peer_certificate
@results
$chain[0] == $iossl->peer_certificate
Truth table0%0/3
A and B
A= @resultsB= $chain[0] == $iossl->peer_certificate
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2509 | 0 | ${*$iossl}{_SSL_ocsp_verify} = $results[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2510 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2511 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2512 | 10 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2513 | 10 | Net::SSLeay::CTX_set_tlsext_status_cb($_,$status_cb) for (values %ctx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2514 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2516 | 14 | ▶ | if ( my $cl = $arg_hash->{SSL_cipher_list} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2517 | 14 | for (values %ctx) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2518 | 14 | ▶ | Net::SSLeay::CTX_set_cipher_list($_, $cl ) || return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2519 | IO::Socket::SSL->error("Failed to set SSL cipher list"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2520 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2521 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2523 | # Main context is default context or any other if no default context. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2524 | 14 | ▶ | my $ctx = $ctx{''} || (values %ctx)[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$ctx{''} || (values %ctx)[0]
MC/DC0%0/2
$ctx{''} || (values %ctx)[0]
$ctx{''}
(values %ctx)[0]
Truth table33%1/3
A || B
A= $ctx{''}B= (values %ctx)[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2525 | 14 | ▶ | if (keys(%ctx) > 1 || ! exists $ctx{''}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
keys %ctx > 1 or not exists $ctx{""}
MC/DC0%0/2
keys %ctx > 1 or not exists $ctx{""}
keys %ctx > 1
not exists $ctx{""}
Truth table33%1/3
A or not(B)
A= keys %ctx > 1B= not exists $ctx{""}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2526 | 0 | ▶ | $can_server_sni or return IO::Socket::SSL->_internal_error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2527 | "Server side SNI not supported for this openssl/Net::SSLeay"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2529 | Net::SSLeay::CTX_set_tlsext_servername_callback($ctx, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2530 | 0 | ▶ | my $ssl = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2531 | 0 | my $host = Net::SSLeay::get_servername($ssl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2532 | 0 | ▶ | $host = '' if ! defined $host; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2533 | 0 | ▶ | my $snictx = $ctx{lc($host)} || $ctx{''} or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ctx{lc $host} || $ctx{''}
MC/DC0%0/2
$ctx{lc $host} || $ctx{''}
$ctx{lc $host}
$ctx{''}
Truth table0%0/3
A || B
A= $ctx{lc $host}B= $ctx{''}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2534 | 0 | ▶ | $DEBUG>1 and DEBUG( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2535 | "cannot get context from servername '$host'"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2536 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2537 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2538 | 0 | ▶ | $DEBUG>1 and DEBUG("set context from servername $host"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2539 | 0 | ▶ | Net::SSLeay::set_SSL_CTX($ssl,$snictx) if $snictx != $ctx; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2540 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2541 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2542 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2544 | 14 | ▶ | if ( my $cb = $arg_hash->{SSL_create_ctx_callback} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2545 | 0 | $cb->($_) for values (%ctx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2548 | 14 | $self->{context} = $ctx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2549 | 14 | $self->{verify_mode} = $arg_hash->{SSL_verify_mode}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2550 | $self->{ocsp_mode} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2551 | defined($arg_hash->{SSL_ocsp_mode}) ? $arg_hash->{SSL_ocsp_mode} : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2552 | 14 | ▶ | $self->{verify_mode} ? IO::Socket::SSL::SSL_OCSP_TRY_STAPLE() : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2553 | 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2554 | 14 | ▶ | $DEBUG>=3 && DEBUG( "new ctx $ctx" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2556 | 14 | ▶ | if ( my $cache = $arg_hash->{SSL_session_cache} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2557 | # use predefined cache | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2558 | 0 | $self->{session_cache} = $cache | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2559 | } elsif ( my $size = $arg_hash->{SSL_session_cache_size}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2560 | 0 | $self->{session_cache} = IO::Socket::SSL::Session_Cache->new( $size ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2561 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2562 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2563 | 14 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2567 | sub session_cache { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2568 | 10 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
session_cache: called CC=5 SCAR=29.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2569 | 10 | ▶ | my $cache = $self->{session_cache} || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'session_cache'} || (return)
MC/DC0%0/1
$self->{'session_cache'} || (return)
$self->{'session_cache'}
Truth table50%1/2
A
A= $self->{'session_cache'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2570 | 0 | my ($addr,$port,$session) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2571 | 0 | ▶ | $port ||= $addr =~s{:(\w+)$}{} && $1; # host:port | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$port ||= $addr =~ s/:(\w+)$// && $1
$addr =~ s/:(\w+)$// && $1
MC/DC0%0/3
$port ||= $addr =~ s/:(\w+)$// && $1
$port
$addr =~ s/:(\w+)$//
$1
Truth table0%0/4
A ||= B && C
A= $portB= $addr =~ s/:(\w+)$//C= $1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2572 | 0 | my $key = "$addr:$port"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2573 | 0 | ▶ | return defined($session) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2574 | ? $cache->add_session($key, $session) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2575 | : $cache->get_session($key); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2576 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2577 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2578 | sub has_session_cache { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2579 | 4 | ▶ | return defined shift->{session_cache}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_session_cache: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2582 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2583 | 0 | ▶ | sub CLONE { %CTX_CREATED_IN_THIS_THREAD = (); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CLONE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2584 | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2585 | 30 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=10 SCAR=29.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2586 | 30 | ▶ | if ( my $ctx = $self->{context} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2587 | 14 | ▶ | $DEBUG>=3 && DEBUG("free ctx $ctx open=".join( " ",keys %CTX_CREATED_IN_THIS_THREAD )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2588 | 14 | ▶ | if ( %CTX_CREATED_IN_THIS_THREAD and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
%CTX_CREATED_IN_THIS_THREAD and delete $CTX_CREATED_IN_THIS_THREAD{$ctx}
MC/DC0%0/2
%CTX_CREATED_IN_THIS_THREAD and delete $CTX_CREATED_IN_THIS_THREAD{$ctx}
%CTX_CREATED_IN_THIS_THREAD
delete $CTX_CREATED_IN_THIS_THREAD{$ctx}
Truth table33%1/3
A and B
A= %CTX_CREATED_IN_THIS_THREADB= delete $CTX_CREATED_IN_THIS_THREAD{$ctx}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2589 | delete $CTX_CREATED_IN_THIS_THREAD{$ctx} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2590 | # remove any verify callback for this context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2591 | 14 | ▶ | if ( $self->{verify_mode}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2592 | 0 | ▶ | $DEBUG>=3 && DEBUG("free ctx $ctx callback" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2593 | 0 | Net::SSLeay::CTX_set_verify($ctx, 0,undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2594 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2595 | 14 | ▶ | if ( $self->{ocsp_error_ref}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2596 | 0 | ▶ | $DEBUG>=3 && DEBUG("free ctx $ctx tlsext_status_cb" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2597 | 0 | Net::SSLeay::CTX_set_tlsext_status_cb($ctx,undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2598 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2599 | 14 | ▶ | $DEBUG>=3 && DEBUG("OK free ctx $ctx" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2600 | 14 | Net::SSLeay::CTX_free($ctx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2601 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2602 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2603 | 30 | delete(@{$self}{'context','session_cache'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2604 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2606 | package IO::Socket::SSL::Session_Cache; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2607 | 26 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2608 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2609 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2610 | 0 | ▶ | my ($class, $size) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2611 | 0 | ▶ | $size>0 or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2612 | 0 | return bless { _maxsize => $size }, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2613 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2614 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2616 | sub get_session { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2617 | 0 | ▶ | my ($self, $key) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_session: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2618 | 0 | ▶ | my $session = $self->{$key} || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{$key} || (return)
MC/DC0%0/1
$self->{$key} || (return)
$self->{$key}
Truth table0%0/2
A
A= $self->{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2619 | 0 | ▶ | return $session->{session} if ($self->{'_head'} eq $session); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2620 | 0 | $session->{prev}->{next} = $session->{next}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2621 | 0 | $session->{next}->{prev} = $session->{prev}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2622 | 0 | $session->{next} = $self->{'_head'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2623 | 0 | $session->{prev} = $self->{'_head'}->{prev}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2624 | 0 | $self->{'_head'}->{prev} = $self->{'_head'}->{prev}->{next} = $session; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2625 | 0 | $self->{'_head'} = $session; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2626 | 0 | return $session->{session}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2627 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2629 | sub add_session { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2630 | 0 | ▶ | my ($self, $key, $val) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_session: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2631 | 0 | ▶ | return if ($key eq '_maxsize' or $key eq '_head'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$key eq "_maxsize" or $key eq "_head"
MC/DC0%0/2
$key eq "_maxsize" or $key eq "_head"
$key eq "_maxsize"
$key eq "_head"
Truth table0%0/3
A or B
A= $key eq "_maxsize"B= $key eq "_head"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2633 | 0 | ▶ | if ( my $have = $self->{$key} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2634 | 0 | Net::SSLeay::SESSION_free( $have->{session} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2635 | 0 | $have->{session} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2636 | 0 | return get_session($self,$key); # will put key on front | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2637 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2638 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2639 | 0 | my $session = $self->{$key} = { session => $val, key => $key }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2641 | 0 | ▶ | if ( keys(%$self) > $self->{_maxsize}+2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2642 | 0 | my $last = $self->{'_head'}->{prev}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2643 | 0 | Net::SSLeay::SESSION_free($last->{session}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2644 | 0 | delete($self->{$last->{key}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2645 | 0 | $self->{'_head'}->{prev} = $self->{'_head'}->{prev}->{prev}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2646 | 0 | ▶ | delete($self->{'_head'}) if ($self->{'_maxsize'} == 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2647 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2649 | 0 | ▶ | if ($self->{'_head'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2650 | 0 | $session->{next} = $self->{'_head'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2651 | 0 | $session->{prev} = $self->{'_head'}->{prev}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2652 | 0 | $self->{'_head'}->{prev}->{next} = $session; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2653 | 0 | $self->{'_head'}->{prev} = $session; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2654 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2655 | 0 | $session->{next} = $session->{prev} = $session; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2656 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2657 | 0 | $self->{'_head'} = $session; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2658 | 0 | return $session; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2659 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2661 | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2662 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2663 | 0 | delete(@{$self}{'_head','_maxsize'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2664 | 0 | for (values %$self) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2665 | 0 | ▶ | Net::SSLeay::SESSION_free($_->{session} || next); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_->{'session'} || (next)
MC/DC0%0/1
$_->{'session'} || (next)
$_->{'session'}
Truth table0%0/2
A
A= $_->{'session'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2666 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2667 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2668 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2669 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2671 | package IO::Socket::SSL::OCSP_Cache; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2673 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2674 | 0 | ▶ | my ($class,$size) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2675 | 0 | ▶ | return bless { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$size || 100
MC/DC0%0/1
$size || 100
$size
Truth table0%0/2
A
A= $size
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2676 | '' => { _lru => 0, size => $size || 100 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2677 | },$class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2678 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2679 | sub get { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2680 | 0 | ▶ | my ($self,$id) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2681 | 0 | ▶ | my $e = $self->{$id} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2682 | 0 | $e->{_lru} = $self->{''}{_lru}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2683 | 0 | ▶ | if ( $e->{expire} && time()<$e->{expire}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$e->{"expire"} and time < $e->{"expire"}
MC/DC0%0/2
$e->{"expire"} and time < $e->{"expire"}
$e->{"expire"}
time < $e->{"expire"}
Truth table0%0/3
A and B
A= $e->{"expire"}B= time < $e->{"expire"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2684 | 0 | delete $self->{$id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2685 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2686 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2687 | 0 | ▶ | if ( $e->{nextUpdate} && time()<$e->{nextUpdate} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$e->{"nextUpdate"} and time < $e->{"nextUpdate"}
MC/DC0%0/2
$e->{"nextUpdate"} and time < $e->{"nextUpdate"}
$e->{"nextUpdate"}
time < $e->{"nextUpdate"}
Truth table0%0/3
A and B
A= $e->{"nextUpdate"}B= time < $e->{"nextUpdate"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2688 | 0 | delete $self->{$id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2689 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2690 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2691 | 0 | return $e; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2692 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2693 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2694 | sub put { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2695 | 0 | ▶ | my ($self,$id,$e) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
put: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2696 | 0 | $self->{$id} = $e; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2697 | 0 | $e->{_lru} = $self->{''}{_lru}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2698 | 0 | my $del = keys(%$self) - $self->{''}{size}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2699 | 0 | ▶ | if ($del>0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2700 | 0 | my @k = sort { $self->{$a}{_lru} <=> $self->{$b}{_lru} } keys %$self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2701 | 0 | delete @{$self}{ splice(@k,0,$del) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2702 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2703 | 0 | return $e; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2704 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2705 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2706 | package IO::Socket::SSL::OCSP_Resolver; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2707 | 26 | *DEBUG = *IO::Socket::SSL::DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2709 | # create a new resolver | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2710 | # $ssl - the ssl object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2711 | # $cache - OCSP_Cache object (put,get) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2712 | # $failhard - flag if we should fail hard on OCSP problems | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2713 | # $certs - list of certs to verify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2714 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2715 | 0 | ▶ | my ($class,$ssl,$cache,$failhard,$certs) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=13 SCAR=52.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2716 | 0 | my (%todo,$done,$hard_error,@soft_error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2717 | 0 | for my $cert (@$certs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2718 | # skip entries which have no OCSP uri or where we cannot get a certid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2719 | # (e.g. self-signed or where we don't have the issuer) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2720 | 0 | my $subj = Net::SSLeay::X509_NAME_oneline(Net::SSLeay::X509_get_subject_name($cert)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2721 | 0 | ▶ | my $uri = Net::SSLeay::P_X509_get_ocsp_uri($cert) or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2722 | 0 | ▶ | $DEBUG>2 && DEBUG("no URI for certificate $subj"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2723 | 0 | push @soft_error,"no ocsp_uri for $subj"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2724 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2725 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2726 | 0 | ▶ | my $certid = eval { Net::SSLeay::OCSP_cert2ids($ssl,$cert) } or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2727 | 0 | ▶ | $DEBUG>2 && DEBUG("no OCSP_CERTID for certificate $subj: $@"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2728 | 0 | push @soft_error,"no certid for $subj: $@"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2729 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2730 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2731 | 0 | ▶ | if (!($done = $cache->get($certid))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2732 | 0 | push @{ $todo{$uri}{ids} }, $certid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2733 | } elsif ( $done->{hard_error} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2734 | # one error is enough to fail validation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2735 | 0 | $hard_error = $done->{hard_error}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2736 | 0 | %todo = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2737 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2738 | } elsif ( $done->{soft_error} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2739 | 0 | push @soft_error,$done->{soft_error}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2740 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2741 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2742 | 0 | ▶ | while ( my($uri,$v) = each %todo) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2743 | 0 | my $ids = $v->{ids}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2744 | 0 | $v->{req} = Net::SSLeay::i2d_OCSP_REQUEST( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2745 | Net::SSLeay::OCSP_ids2req(@$ids)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2746 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2747 | 0 | ▶ | $hard_error ||= '' if ! %todo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$hard_error ||= ""
MC/DC0%0/1
$hard_error ||= ""
$hard_error
Truth table0%0/2
A
A= $hard_error
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2748 | 0 | ▶ | return bless { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2749 | ssl => $ssl, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2750 | cache => $cache, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2751 | failhard => $failhard, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2752 | hard_error => $hard_error, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2753 | soft_error => @soft_error ? join("; ",@soft_error) : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2754 | todo => \%todo, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2755 | },$class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2756 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2758 | # return current result, e.g. '' for no error, else error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2759 | # if undef we have no final result yet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2760 | 0 | ▶ | sub hard_error { return shift->{hard_error} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hard_error: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2761 | 0 | ▶ | sub soft_error { return shift->{soft_error} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
soft_error: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2762 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2763 | # return hash with uri => ocsp_request_data for open requests | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2764 | sub requests { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2765 | 0 | ▶ | my $todo = shift()->{todo}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
requests: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2766 | 0 | return map { ($_,$todo->{$_}{req}) } keys %$todo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2767 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2768 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2769 | # add new response | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2770 | sub add_response { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2771 | 0 | ▶ | my ($self,$uri,$resp) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_response: not called CC=28 SCAR=67.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2772 | 0 | my $todo = delete $self->{todo}{$uri}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2773 | 0 | ▶ | return $self->{error} if ! $todo || $self->{error}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $todo or $self->{"error"}
MC/DC0%0/2
not $todo or $self->{"error"}
not $todo
$self->{"error"}
Truth table0%0/3
not(A) or B
A= not $todoB= $self->{"error"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2774 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2775 | 0 | my ($req,@soft_error,@hard_error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2777 | # do we have a response | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2778 | 0 | ▶ | if (!$resp) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2779 | 0 | @soft_error = "http request failed" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2780 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2781 | # is it an valid OCSP_RESPONSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2782 | 0 | } elsif ( ! eval { $resp = Net::SSLeay::d2i_OCSP_RESPONSE($resp) }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2783 | 0 | @soft_error = "invalid response (no OCSP_RESPONSE)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2784 | # hopefully short-time error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2785 | $self->{cache}->put($_,{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2786 | soft_error => "@soft_error", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2787 | expire => time()+10, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2788 | 0 | }) for (@{$todo->{ids}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2789 | # is the OCSP response status success | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2790 | } elsif ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2791 | ( my $status = Net::SSLeay::OCSP_response_status($resp)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2792 | != Net::SSLeay::OCSP_RESPONSE_STATUS_SUCCESSFUL() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2793 | ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2794 | 0 | @soft_error = "OCSP response failed: ". | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2795 | Net::SSLeay::OCSP_response_status_str($status); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2796 | # hopefully short-time error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2797 | $self->{cache}->put($_,{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2798 | soft_error => "@soft_error", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2799 | expire => time()+10, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2800 | 0 | }) for (@{$todo->{ids}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2801 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2802 | # does nonce match the request and can the signature be verified | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2803 | } elsif ( ! eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2804 | 0 | $req = Net::SSLeay::d2i_OCSP_REQUEST($todo->{req}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2805 | 0 | Net::SSLeay::OCSP_response_verify($self->{ssl},$resp,$req); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2806 | }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2807 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2808 | 0 | @soft_error = $@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2809 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2810 | 0 | my @err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2811 | 0 | ▶ | while ( my $err = Net::SSLeay::ERR_get_error()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2812 | 0 | push @soft_error, Net::SSLeay::ERR_error_string($err); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2813 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2814 | 0 | ▶ | @soft_error = 'failed to verify OCSP response' if ! @soft_error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2815 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2816 | # configuration problem or we don't know the signer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2817 | $self->{cache}->put($_,{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2818 | soft_error => "@soft_error", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2819 | expire => time()+120, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2820 | 0 | }) for (@{$todo->{ids}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2821 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2822 | # extract results from response | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2823 | } elsif ( my @result = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2824 | 0 | Net::SSLeay::OCSP_response_results($resp,@{$todo->{ids}})) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2825 | 0 | my (@found,@miss); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2826 | 0 | for my $rv (@result) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2827 | 0 | ▶ | if ($rv->[2]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2828 | 0 | push @found,$rv->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2829 | 0 | ▶ | if (!$rv->[1]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2830 | # no error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2831 | 0 | $self->{cache}->put($rv->[0],$rv->[2]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2832 | } elsif ( $rv->[2]{statusType} == | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2833 | Net::SSLeay::V_OCSP_CERTSTATUS_GOOD()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2834 | # soft error, like response after nextUpdate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2835 | 0 | push @soft_error,$rv->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2836 | $self->{cache}->put($rv->[0],{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2837 | 0 | %{$rv->[2]}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2838 | soft_error => "@soft_error", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2839 | expire => time()+120, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2840 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2841 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2842 | # hard error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2843 | 0 | $self->{cache}->put($rv->[0],$rv->[2]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2844 | 0 | push @hard_error, $rv->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2845 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2846 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2847 | 0 | push @miss,$rv->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2848 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2849 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2850 | 0 | ▶ | if (@miss && @found) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@miss and @found
MC/DC0%0/2
@miss and @found
@miss
@found
Truth table0%0/3
A and B
A= @missB= @found
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2851 | # we sent multiple responses, but server answered only to one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2852 | # try again | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2853 | 0 | $self->{todo}{$uri} = $todo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2854 | 0 | $todo->{ids} = \@miss; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2855 | 0 | $todo->{req} = Net::SSLeay::i2d_OCSP_REQUEST( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2856 | Net::SSLeay::OCSP_ids2req(@miss)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2857 | 0 | ▶ | $DEBUG>=2 && DEBUG("$uri just answered ".@found." of ".(@found+@miss)." requests"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2858 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2859 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2860 | 0 | @soft_error = "no data in response"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2861 | # probably configuration problem | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2862 | $self->{cache}->put($_,{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2863 | soft_error => "@soft_error", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2864 | expire => time()+120, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2865 | 0 | }) for (@{$todo->{ids}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2866 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2867 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2868 | 0 | ▶ | Net::SSLeay::OCSP_REQUEST_free($req) if $req; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2869 | 0 | ▶ | if ($self->{failhard}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2870 | 0 | push @hard_error,@soft_error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2871 | 0 | @soft_error = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2872 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2873 | 0 | ▶ | if (@soft_error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2874 | 0 | ▶ | $self->{soft_error} .= "; " if $self->{soft_error}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2875 | 0 | $self->{soft_error} .= "$uri: ".join('; ',@soft_error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2876 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2877 | 0 | ▶ | if (@hard_error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2878 | 0 | $self->{hard_error} = "$uri: ".join('; ',@hard_error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2879 | 0 | %{$self->{todo}} = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2880 | 0 | } elsif ( ! %{$self->{todo}} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2881 | 0 | $self->{hard_error} = '' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2882 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2883 | 0 | return $self->{hard_error}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2884 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2885 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2886 | # make all necessary requests to get OCSP responses blocking | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2887 | sub resolve_blocking { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2888 | 0 | ▶ | my ($self,%args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolve_blocking: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2889 | 0 | ▶ | while ( my %todo = $self->requests ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2890 | 0 | ▶ | eval { require HTTP::Tiny } or die "need HTTP::Tiny installed"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2891 | # OCSP responses have their own signature, so we don't need SSL verification | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2892 | 0 | my $ua = HTTP::Tiny->new(verify_SSL => 0,%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2893 | 0 | ▶ | while (my ($uri,$reqdata) = each %todo) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2894 | 0 | ▶ | $DEBUG && DEBUG("sending OCSP request to $uri"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2895 | 0 | my $resp = $ua->request('POST',$uri, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2896 | headers => { 'Content-type' => 'application/ocsp-request' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2897 | content => $reqdata | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2898 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2899 | 0 | ▶ | $DEBUG && DEBUG("got OCSP response from $uri code=$resp->{status}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2900 | defined ($self->add_response($uri, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2901 | 0 | ▶ | $resp->{success} && $resp->{content})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$resp->{'success'} && $resp->{'content'}
MC/DC0%0/2
$resp->{'success'} && $resp->{'content'}
$resp->{'success'}
$resp->{'content'}
Truth table0%0/3
A && B
A= $resp->{'success'}B= $resp->{'content'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2902 | && last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2903 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2904 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2905 | 0 | ▶ | $DEBUG>=2 && DEBUG("no more open OCSP requests"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2906 | 0 | return $self->{hard_error}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2907 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2908 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2909 | 26 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2910 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2911 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||