Branch Coverage

blib/lib/IO/Socket/SSL.pm
Criterion Covered Total %
branch 711 1228 57.9


line true false branch
28 0 80 unless do { local $SIG{'__DIE__'}; eval { do { require WeakRef; "WeakRef"->import("weaken"); 1 } } unless eval { do { require Scalar::Util; "Scalar::Util"->import("weaken"); 1 } } }
31 0 80 unless eval { do { require Scalar::Util; "Scalar::Util"->import("weaken"); 1 } }
94 80 0 defined &Net::SSLeay::CTX_set_tmp_ecdh && ($openssl_version != 268439631 || length pack('P', 0) == 4) ? :
0 80 defined &Net::SSLeay::CTX_set_ecdh_auto ? :
0 80 $openssl_version >= 269484047 ? :
103 0 80 defined &Net::SSLeay::CTX_set1_curves_list ? :
0 80 defined &Net::SSLeay::CTX_set1_groups_list ? :
119 0 80 if (defined &Net::SSLeay::SESSION_up_ref)
123 0 0 if ($session_upref and defined &Net::SSLeay::CTX_sess_set_new_cb and defined &Net::SSLeay::CTX_sess_set_remove_cb)
132 0 80 if (my $c = defined &Net::SSLeay::CTX_get0_param && eval { do { Net::SSLeay::X509_V_FLAG_PARTIAL_CHAIN() } })
141 80 0 unless (defined &Net::SSLeay::clear_mode)
149 0 80 if ($openssl_version >= 269488128)
157 0 0 if ($on) { }
164 80 0 if ($openssl_version >= 268435456)
230 79 80 unless &Net::SSLeay::library_init()
240 80 0 $can_ecdh eq 'tmp_ecdh' ? :
0 80 $can_ecdh eq 'can_auto' ? :
0 80 $can_ecdh eq 'auto' ? :
255 0 80 unless $dh
287 0 80 if not do { local $SIG{'__DIE__'}; local $SIG{'__WARN__'}; eval { do { &dualvar(0, ""); 1 } } }
376 80 0 if ($ip6)
379 79 1 if (eval { do { require IO::Socket::IP; 'IO::Socket::IP'->VERSION(0.31) } }) { }
0 1 elsif (eval { do { require IO::Socket::INET6; 'IO::Socket::INET6'->VERSION(2.62) } }) { }
401 1 79 unless ($ip6)
405 0 1 unless (defined $ip6)
420 0 0 unless $DEBUG
422 0 0 if ($sub =~ /^IO::Socket::SSL::(?:error|(_internal_error))$/) { }
423 0 0 if $1
428 0 0 if length $file > 20
429 0 0 if @_
492 3 156 if (@_)
494 0 3 if (@_ > 1) { }
3 0 elsif (my $path = shift()) { }
504 114 45 if defined $ca_detected
509 0 0 &Net::SSLeay::SSLeay_version(4) =~ /^OPENSSLDIR: "(.+)"$/ ? :
45 0 &Net::SSLeay::SSLeay_version(5) =~ /^OPENSSLDIR: "(.+)"$/ ? :
517 45 0 if (opendir my $dh, $dir)
519 0 45 unless open my $fh, "<", "$dir/$f"
521 0 45 unless $line =~ /^-+BEGIN (X509 |TRUSTED |)CERTIFICATE-/
529 0 45 if (open my $fh, "<", $file)
531 0 0 unless $line =~ /^-+BEGIN (X509 |TRUSTED |)CERTIFICATE-/
537 0 0 if not %default_ca and do { local $SIG{'__DIE__'}; eval { do { require Mozilla::CA; 1 } } }
556 0 1 if (/^inet4$/i) { }
0 1 elsif (/^inet6$/i) { }
1 0 elsif (/^:?debug(\d+)/) { }
562 0 0 unless (UNIVERSAL::isa($class, "IO::Socket::INET6") or UNIVERSAL::isa($class, "IO::Socket::IP"))
622 0 114 unless $self
634 2 112 if defined $blocking
636 2 112 unless $self->configure_SSL($arg_hash)
638 68 44 if ($arg_hash->{$family_key} ||= $arg_hash->{'Domain'} || $arg_hash->{'Family'})
644 68 0 if $IOCLASS eq "IO::Socket::IP" and not defined $arg_hash->{'GetAddrInfoFlags'}
646 6 106 unless $self->SUPER::configure($arg_hash)
649 2 104 if defined $blocking and not $blocking
658 190 79 unless (defined $is_server)
663 0 269 if $FILTER_SSL_ARGS
670 2 267 unless do { *$self }->{'_SSL_ctx'} = "IO::Socket::SSL::SSL_Context"->new($arg_hash)
680 59 36 if ($err == $Net_SSLeay_ERROR_WANT_READ) { }
2 34 elsif ($err == $Net_SSLeay_ERROR_WANT_WRITE) { }
688 61 0 if ref $self
697 0 74 if do { *$self }->{'_SSL_opened'}
699 74 0 unless (do { *$self }->{'_SSL_opening'})
704 0 74 if $DEBUG >= 2
705 0 74 unless $self->SUPER::connect(@_)
706 0 74 if $DEBUG >= 2
715 12 62 if defined $sh and not $sh
723 2 174 @_ > 1 ? :
724 0 176 if do { *$self }->{'_SSL_opened'}
727 172 4 unless (do { *$self }->{'_SSL_opening'})
729 0 172 if $DEBUG >= 2
734 0 172 unless defined $fileno
740 0 172 if $use_threads
744 12 160 if ($ctx->{'session_cache'})
749 6 0 $port ? :
753 0 172 unless &Net::SSLeay::set_fd($ssl, $fileno)
756 0 172 if $DEBUG >= 2 or do { *$self }->{'_SSL_msg_callback'}
758 172 0 if ($can_client_sni) { }
0 0 elsif ($arg_hash->{'SSL_hostname'}) { }
760 21 151 if (exists $arg_hash->{'SSL_hostname'}) { }
62 89 elsif ($host = $arg_hash->{'PeerAddr'} || $arg_hash->{'PeerHost'}) { }
768 62 0 if not $host =~ /[a-z_]/i or $host =~ /:/
772 21 151 if ($host) { }
773 0 21 if $DEBUG >= 2
776 0 151 if $DEBUG >= 2
782 0 0 if $DEBUG >= 2
785 95 75 unless $arg_hash->{'PeerAddr'} or $arg_hash->{'PeerHost'}
786 97 75 if ($ctx->{'verify_name_ref'})
790 44 53 unless (defined $host)
791 44 0 if ($host = $arg_hash->{'PeerAddr'} || $arg_hash->{'PeerHost'})
805 1 171 if ($ocsp & 1) { }
0 171 elsif (not $can_ocsp_staple) { }
95 76 elsif ($ocsp & 18) { }
808 0 0 if $ocsp & 2
814 0 95 if $DEBUG >= 2
817 8 164 if ($ctx->{'session_cache'} and my $session = $ctx->{'session_cache'}->get_session($arg_hash->{'SSL_session_key'}))
829 2 174 exists $args->{'Timeout'} ? :
830 17 159 if (defined $timeout and $timeout > 0 and $self->blocking(0)) { }
831 0 17 if $DEBUG >= 2
837 0 159 if $auto_retry
844 0 211 if $DEBUG >= 3
847 0 211 if $DEBUG >= 3
848 69 142 if ($rv < 0) { }
0 142 elsif ($rv == 0) { }
849 29 40 if (my $err = $self->_skip_rw_error($ssl, $rv))
853 0 29 if $DEBUG >= 1
857 0 40 if $DEBUG >= 2
860 4 36 unless defined $timeout
864 36 0 if ($timeout > 0) { }
867 0 36 if $DEBUG >= 2
868 0 0 $IO::Socket::SSL::SSL_ERROR == 47017704 ? :
36 0 $IO::Socket::SSL::SSL_ERROR == 46977424 ? :
873 0 0 if $DEBUG >= 2
876 1 35 unless ($rv)
877 0 1 if $DEBUG >= 2
887 0 35 if $DEBUG >= 2
895 0 0 if $DEBUG >= 2
902 0 142 if $DEBUG >= 2
906 12 130 if (defined $timeout)
913 1 141 if (my $ocsp_result = do { *$self }->{'_SSL_ocsp_verify'}) { }
0 141 elsif ($ctx->{'ocsp_mode'} & 2) { }
915 1 0 if ($ocsp_result->[0] > 0) { }
0 0 elsif ($ocsp_result->[0] < 0) { }
916 0 1 if $DEBUG >= 3
922 0 0 if $DEBUG >= 3
926 0 0 if $DEBUG >= 3
936 12 130 if (not %sess_cb and $ctx->{'session_cache'} and my $session = &Net::SSLeay::get1_session($ssl))
959 0 96 if ($af == 10) { }
979 58 0 unless ($socket)
981 0 58 if $DEBUG >= 2
983 0 58 if $DEBUG >= 2
987 16 42 if (defined $sh and not $sh)
993 0 16 if $DEBUG >= 2
994 0 16 wantarray ? :
998 3 39 unless $self->accept_SSL($socket)
999 0 39 if $DEBUG >= 2
1001 2 37 wantarray ? :
1006 42 80 @_ && UNIVERSAL::isa($_[0], 'IO::Handle') ? :
1007 9 113 @_ > 1 ? :
1010 119 3 unless (do { *$self }->{'_SSL_opening'})
1011 0 119 if $DEBUG >= 2
1013 42 77 if ($socket != $self)
1022 0 119 unless defined $fileno
1028 0 119 if $use_threads
1032 0 119 unless &Net::SSLeay::set_fd($ssl, $fileno)
1035 0 119 if $DEBUG >= 2 or do { *$self }->{'_SSL_msg_callback'}
1045 9 113 exists $args->{'Timeout'} ? :
1046 14 108 if (defined $timeout and $timeout > 0 and $socket->blocking(0)) { }
1052 0 108 if $auto_retry
1061 0 136 if $DEBUG >= 3
1062 21 115 if ($rv < 0) { }
13 102 elsif ($rv == 0) { }
1063 3 18 if (my $err = $socket->_skip_rw_error($ssl, $rv))
1072 3 15 unless defined $timeout
1076 15 0 if ($timeout > 0) { }
1079 0 0 $IO::Socket::SSL::SSL_ERROR == 47017704 ? :
15 0 $IO::Socket::SSL::SSL_ERROR == 46977424 ? :
1086 1 14 unless ($rv)
1109 0 102 if $DEBUG >= 2
1113 12 90 if (defined $timeout)
1127 0 0 if $DEBUG >= 2
1129 0 0 if (my $cb = do { *$self }->{'_SSL_msg_callback'})
1140 0 0 if (@_)
1141 0 0 if ($_[0]) { }
1143 0 0 unless $ssleay_set_msg_callback
1153 0 0 if ($ssleay_set_msg_callback and my $ssl = do { *$self }->{'_SSL_object'})
1155 0 0 $DEBUG >= 2 || do { *$self }->{'_SSL_msg_callback'} ? :
1178 1 0 defined $rwerr ? :
0 1 if (my $err = $self->_skip_rw_error($ssl, defined $rwerr ? $rwerr : -1))
1181 0 0 if (not $! and $err == $Net_SSLeay_ERROR_SSL || $err == $Net_SSLeay_ERROR_SYSCALL)
1192 6088 28 unless defined $$buffer
1194 1 6115 if ($offset > length $$buffer)
1204 5 1 $self->blocking ? :
6 0 if do { *$self }->{'_SSL_object'}
1216 6110 0 if do { *$self }->{'_SSL_object'}
1226 1 5 if do { *$self }->{'_SSL_object'}
1231 0 5 unless defined CORE::recv($self, my $buf, $_[1], 2)
1232 0 5 $_[2] ? :
1246 0 7550 if $offset > $buf_len
1248 0 7550 if $offset == $buf_len
1252 59 7491 if ($write_all) { }
1253 0 59 $length < $buf_len - $offset ? :
1256 0 59 if not $written and $errs
1260 4 7487 if $written <= 0
1262 4 7546 unless (defined $written)
1263 2 2 if (my $err = $self->_skip_rw_error($ssl, -1))
1265 2 0 if $err == $Net_SSLeay_ERROR_SYSCALL
1278 60 0 if do { *$self }->{'_SSL_object'}
1289 7490 0 if do { *$self }->{'_SSL_object'}
1308 2 0 if $self->read($buffer, 1, 0)
1313 0 83 unless do { *$self }->{'_SSL_object'}
1315 7 76 if (not defined $/ or wantarray)
1321 0 14 if (not defined $rv) { }
7 7 elsif (not $rv) { }
1322 0 0 if $! == 4
1323 0 0 if $! == 11 or $! == 11
1330 2 5 if (not defined $/) { }
1 4 elsif (ref $/) { }
1 3 elsif ($/ eq '') { }
1334 0 1 unless $size > 0
1344 1 75 if (ref $/)
1347 0 1 unless $size > 0
1351 0 1 if (not defined $rv) { }
0 1 elsif (not $rv) { }
1352 0 0 if $! == 4
1353 0 0 if $! == 11 or $! == 11
1362 1 74 $/ eq '' ? :
1367 0 75 unless my $ssl = $self->_get_ssl_object
1372 21 58 if (not defined $poke or $poke eq "")
1373 1 20 if $! == 4
1380 58 20 if ($pending and (my $pb = &Net::SSLeay::peek($ssl, $pending)) ne '') { }
1384 19 1 $buf eq '' ? :
1386 58 0 unless ($eod)
1388 3 55 if ($pos < 0) { }
1395 55 3 if ($eod)
1396 1 54 if ($delim1 ne "")
1407 58 0 if ($self->sysread(my $p, $skip, 0))
1411 0 0 unless $! == 4
1414 55 0 if ($eod and $delim1 eq '' || $eod < length $buf)
1424 0 245 ref $_[0] eq 'HASH' ? :
1426 0 245 unless $self->stop_SSL("SSL_fast_shutdown", 1, %$close_args, "_SSL_ioclass_downgrade", 0)
1432 51 194 unless ($close_args->{'_SSL_in_DESTROY'})
1447 0 291 ref $_[0] eq 'HASH' ? :
1448 1 290 unless do { *$self }->{'_SSL_opened'}
1450 289 2 if (my $ssl = do { *$self }->{'_SSL_object'})
1451 0 289 if (delete do { *$self }->{'_SSL_opening'}) { }
94 195 elsif (not $stop_args->{'SSL_no_shutdown'}) { }
1459 0 85 exists $stop_args->{'Timeout'} ? :
9 85 !$self->blocking ? :
1460 3 91 if ($timeout)
1466 49 10 if ($status & 1 and $status & 2 || $stop_args->{'SSL_fast_shutdown'})
1473 45 59 if ((do { *$self }->{'_SSL_opened'} || 0) <= 0)
1483 0 59 if ($rv < 0)
1485 0 0 unless ($timeout)
1486 0 0 if (my $err = $self->_skip_rw_error($ssl, $rv))
1488 0 0 if $err == $Net_SSLeay_ERROR_SYSCALL
1498 0 0 if $wait <= 0
1501 0 0 if ($err == $Net_SSLeay_ERROR_WANT_READ) { }
0 0 elsif ($err == $Net_SSLeay_ERROR_WANT_READ) { }
1511 10 49 if $rv > 0
1513 3 91 if $timeout
1519 35 254 if (my $cert = delete do { *$self }->{'_SSL_certificate'})
1529 3 288 if ($stop_args->{'SSL_ctx_free'})
1531 3 0 if $ctx
1535 97 194 unless ($stop_args->{'_SSL_in_DESTROY'})
1538 46 51 if ($downgrade or not defined $downgrade)
1540 39 7 if (my $orig_class = delete do { *$self }->{'_SSL_ioclass_upgraded'})
1545 39 0 if @sslkeys
1556 7540 114 defined $fn ? :
1588 0 156 unless ref $socket
1589 1 155 @_ == 1 ? :
1590 11 145 exists $arg_hash->{'Timeout'} ? :
1592 0 156 unless ($original_class)
1593 0 0 unless $socket = ($original_class = $IO::Socket::SSL::ISA[0])->new_from_fd($socket, "<+")
1597 156 0 UNIVERSAL::can($socket, 'fileno') ? :
1599 1 155 unless defined $original_fileno
1603 0 155 unless $socket->configure_SSL($arg_hash)
1606 154 1 if $class ne $original_class
1610 151 4 if (not defined $start_handshake or $start_handshake) { }
1612 0 151 if $DEBUG >= 2
1615 57 94 do { *$socket }->{'_SSL_arguments'}{'SSL_server'} ? :
1617 113 38 if ($result) { }
1618 0 113 unless $was_blocking
1622 38 0 if ($original_class)
1624 0 38 if not $was_blocking and $socket->can("blocking")
1630 0 4 if $DEBUG >= 2
1639 1 0 if (length $_[0] < 4)
1641 1 0 unless length $mode
1664 0 3 if @chain and not $self->peer_certificate
1665 0 3 if (do { *$self }->{'_SSL_arguments'}{'SSL_server'})
1669 0 0 if (my $peer = &Net::SSLeay::get_peer_certificate($ssl))
1702 0 80 unless my $ssl = $self->_get_ssl_object
1705 0 0 if $reload and do { *$self }->{'_SSL_certificate'}
1707 0 80 unless my $cert = (do { *$self }->{'_SSL_certificate'} ||= &Net::SSLeay::get_peer_certificate($ssl))
1710 14 66 if ($field) { }
1711 0 14 unless my $sub = $dispatcher{$field}
1724 4 2 if ($field) { }
1725 0 4 unless my $sub = $dispatcher{$field}
1831 203 0 unless (ref $scheme)
1832 0 203 if $DEBUG >= 3
1836 0 203 unless %$scheme
1842 0 203 if $DEBUG >= 3
1844 0 203 if (my $sub = $scheme->{'callback'})
1852 12 191 if ($identity =~ /:/) { }
46 145 elsif (my(@ip) = $identity =~ /^(\d+)(?:\.(\d+)\.(\d+)\.(\d+)|[\d\.]*)$/) { }
1854 3 9 if $identity =~ /[^\da-fA-F:\.]/
1855 0 9 unless $ipn = inet_pton(10, $identity)
1858 178 6 if defined $_
3 43 if 4 != @ip or 4 != grep({$_ < 256 if defined $_;} @ip)
1862 5 140 if ($identity =~ /[^a-zA-Z0-9_.\-]/)
1863 0 5 if $identity =~ /\0/
1864 0 5 unless $identity = idn_to_ascii($identity)
1866 2 3 if $identity =~ /[^a-zA-Z0-9_.\-]/
1875 1 309 if $name eq ""
1887 116 193 if ($wtyp eq 'anywhere' and $name =~ /^([a-zA-Z0-9_\-]*)\*(.+)/) { }
26 167 elsif ($wtyp =~ /^(?:full_label|leftmost)$/ and $name =~ /^\*(\..+)$/) { }
1888 4 112 if $1 ne "" and substr($identity, 0, 4) eq "xn--"
1896 56 82 if ($identity =~ /$pattern/)
1897 56 0 unless defined $publicsuffix
1899 0 56 if $publicsuffix eq ""
1902 56 0 $tld ? :
41 15 if @labels > ($tld ? 0 + @$tld : 1)
1911 42 319 if ($ipn and $type == GEN_IPADD()) { }
222 147 elsif (not $ipn and $type == GEN_DNS()) { }
1914 35 7 if $ipn eq $name
1919 41 181 if &$check_name($name, $identity, $scheme->{'wildcards_in_alt'}, $publicsuffix)
1924 105 14 if ($scheme->{'check_cn'} eq "always" or $scheme->{'check_cn'} eq "when_only" and not $alt_dnsNames)
1926 88 17 if (not $ipn) { }
17 0 elsif ($scheme->{'ip_in_cn'}) { }
1927 44 44 if &$check_name($commonName, $identity, $scheme->{'wildcards_in_cn'}, $publicsuffix)
1930 5 12 if ($identity eq $commonName)
1933 0 0 $scheme->{'ip_in_cn'} == 6 ? :
5 0 $scheme->{'ip_in_cn'} == 4 ? :
3 2 if $scheme->{'ip_in_cn'} == 4 ? length $ipn == 4 : ($scheme->{'ip_in_cn'} == 6 ? length $ipn == 16 : 1)
1954 0 8 unless my $ssl = $self->_get_ssl_object
1962 8 14 $key_only ? :
1970 0 22 unless my $fp = get_fingerprint_bin($self, $algo, $cert, $key_only)
1971 8 14 $key_only ? :
1981 0 28 unless my $version = &Net::SSLeay::version($ssl)
1983 0 0 $version == 65279 ? :
0 0 $version == 2 ? :
0 0 $version == 768 ? :
6 0 $version == 769 ? :
6 6 $version == 770 ? :
16 12 $version == 771 ? :
0 28 $version == 772 ? :
2014 1 1 $ctx->{'ocsp_mode'} & 8 ? :
0 2 @_ ? :
2023 46 0 $oe ? :
2031 1 44 if (defined $error_trap and ref $error_trap eq 'CODE') { }
36 8 elsif (do { *$self }->{'_SSL_ioclass_upgraded'} or do { *$self }->{'_SSL_arguments'}{'SSL_keepSocketOnError'}) { }
2036 0 36 if $DEBUG >= 3
2042 45 0 if $saved_error
2068 19 56 if not ref $self and $CURRENT_SSL_OBJECT
2069 72 3 if (ref $self) { }
2071 47 25 if (not $oe or $oe->[1] <= $severity) { }
2074 0 47 if $DEBUG
2076 0 25 if $DEBUG
2080 0 3 if $DEBUG
2091 0 44 if $DEBUG >= 2
2093 44 3 if @err
2094 47 0 if $error
2119 0 284 unless my $self = shift()
2120 194 90 if (my $ssl = do { *$self }->{'_SSL_object'})
2122 194 0 if (not $use_threads or delete $CREATED_IN_THIS_THREAD{$ssl})
2140 0 2 ref $_[0] eq 'HASH' ? :
2192 0 0 if (ref $sub) { }
0 0 elsif ($sub eq 'use_defaults') { }
2198 0 0 $is_server ? :
2208 0 2 unless $can_npn
2215 0 2 unless $can_alpn
2237 1 0 if wantarray
2308 269 7 ref $_[0] eq 'HASH' ? :
2311 101 175 $is_server ? :
2314 6 270 if ($defaults{'SSL_reuse_ctx'})
2317 0 6 if grep {/^SSL_(?!verifycn_name|hostname)$/;} keys %$arg_hash
2319 276 0 if %defaults
2321 26 250 if (my $ctx = $arg_hash->{'SSL_reuse_ctx'})
2322 24 2 if ($ctx->isa('IO::Socket::SSL::SSL_Context') and $ctx->{'context'}) { }
2 0 elsif ($ctx = do { *$ctx }->{'_SSL_ctx'}) { }
2334 6 153 if (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")
2342 32 218 if ($arg_hash->{'SSL_ca'}) { }
0 218 elsif ($arg_hash->{'SSL_ca_path'}) { }
61 157 elsif ($arg_hash->{'SSL_ca_file'}) { }
2352 240 10 unless defined $arg_hash->{'SSL_use_cert'}
2364 0 2000 if defined $arg_hash->{$_} and $arg_hash->{$_} eq ""
2367 368 132 unless defined(my $file = $arg_hash->{$_})
2368 12 120 ref $file eq 'HASH' ? :
2369 0 164 unless open my $fh, "<", $f
2374 87 163 if ($verify_mode != $Net_SSLeay_VERIFY_NONE) { }
0 163 elsif ($verify_mode ne '0') { }
2387 84 0 if (not $is_server and $verify_mode & 1 and !$vcn_scheme || $vcn_scheme ne 'none')
2397 4 179 if $vcb
2398 14 169 unless $ok
2400 85 84 if $depth != 0
2403 0 84 unless ($host)
2404 0 0 if ($vcn_scheme)
2419 19 65 unless ($rv)
2427 89 161 if ($is_server)
2428 0 89 if ($arg_hash->{'SSL_ticket_keycb'} and not $can_tckt_keycb)
2439 0 710 unless m[^(!?)(?:(SSL(?:v2|v3|v23|v2/3))|(TLSv1(?:_?[123])?))$]i
2443 460 250 if ($not) { }
2446 0 250 if $ver and $v ne $ver
2454 4 240 $ver eq 'TLSv1_2' ? :
2 244 $ver eq 'TLSv1_1' ? :
2 246 $ver eq 'TLSv1' ? :
1 248 $ver eq 'SSLv3' ? :
0 249 $ver eq 'SSLv2' ? :
1 249 $ver eq 'TLSv1_3' ? :
2 248 unless my $ctx_new_sub = $ver eq "TLSv1_3" ? $CTX_tlsv1_3_new : UNIVERSAL::can("Net::SSLeay", $ver eq "SSLv2" ? "CTX_v2_new" : ($ver eq "SSLv3" ? "CTX_v3_new" : ($ver eq "TLSv1" ? "CTX_tlsv1_new" : ($ver eq "TLSv1_1" ? "CTX_tlsv1_1_new" : ($ver eq "TLSv1_2" ? "CTX_tlsv1_2_new" : "CTX_new")))))
2468 89 159 if ($is_server)
2471 183 173 unless my $val = $arg_hash->{$opt}
2472 12 161 if (ref $val eq "HASH")
2479 2 20 $host =~ /%/ ? :
2482 242 6 unless %ctx
2487 2 262 if ($host =~ /^([^%]*)%/)
2488 0 2 unless $ctx = $ctx{$1}
2490 0 2 if (my(@k) = grep({not /^SSL_(?:cert|key)(?:_file)?$/;} keys %$arg_hash))
2495 0 2 unless $can_multi_cert
2501 0 262 unless $ctx = &$ctx_new_sub()
2503 0 262 if $use_threads
2507 99 163 if $arg_hash->{'SSL_honor_cipher_order'}
2509 19 243 if ($ver eq "SSLv23" and not $ssl_op & $SSL_OP_NO{'SSLv3'})
2519 0 262 if $check_partial_chain
2525 9 253 if ($arg_hash->{'SSL_server'} and my $id = $arg_hash->{'SSL_session_id_context'} || $arg_hash->{'SSL_verify_mode'} & 1 && "$ctx")
2538 0 262 $arg_hash->{'SSL_mode_release_buffers'} ? :
2541 3 259 if (my $proto_list = $arg_hash->{'SSL_npn_protocols'})
2542 0 3 unless $can_npn
2544 2 1 if ($arg_hash->{'SSL_server'}) { }
2554 3 259 if (my $proto_list = $arg_hash->{'SSL_alpn_protocols'})
2555 0 3 unless $can_alpn
2557 2 1 if ($arg_hash->{'SSL_server'}) { }
2564 0 262 if ($arg_hash->{'SSL_ticket_keycb'})
2566 0 0 ref $cb eq 'CODE' ? :
2573 107 155 if ($arg_hash->{'SSL_ca'} or defined $arg_hash->{'SSL_ca_file'} or defined $arg_hash->{'SSL_ca_path'}) { }
155 0 elsif (my(%ca) = IO::Socket::SSL::default_ca()) { }
2577 0 107 if ref $file eq "SCALAR" and not $$file
2579 0 107 if ref $dir eq "SCALAR" and not $$dir
2580 32 75 if ($arg_hash->{'SSL_ca'})
2583 0 33 unless &Net::SSLeay::X509_STORE_add_cert($store, $_)
2588 0 107 if ref $dir
2589 0 107 if ($file || $dir and not &Net::SSLeay::CTX_load_verify_locations($ctx, scalar($file || ''), scalar($dir || '')))
2591 0 0 if $verify_mode != $Net_SSLeay_VERIFY_NONE
2598 0 155 if ref $dir
2599 0 155 if (not &Net::SSLeay::CTX_load_verify_locations($ctx, scalar($ca{'SSL_ca_file'} || ''), scalar($dir || '')) and $verify_mode != $Net_SSLeay_VERIFY_NONE)
2607 9 253 if ($is_server and $verify_mode & $Net_SSLeay_VERIFY_PEER)
2608 0 9 if ($arg_hash->{'SSL_client_ca'})
2610 0 0 unless &Net::SSLeay::CTX_add_client_CA($ctx, $_)
2615 0 9 if ($arg_hash->{'SSL_client_ca_file'})
2617 0 0 unless my $list = &Net::SSLeay::load_client_CA_file($arg_hash->{'SSL_client_ca_file'})
2625 0 262 if ($arg_hash->{'SSL_check_crl'})
2627 0 0 if ($arg_hash->{'SSL_crl_file'})
2631 0 0 if ($crl) { }
2641 262 0 if $X509_STORE_flags
2646 12 250 if $arg_hash->{'SSL_passwd_cb'}
2650 31 233 if (my $x509 = $arg_hash->{'SSL_cert'}) { }
80 153 elsif (my $f = $arg_hash->{'SSL_cert_file'}) { }
2654 1 30 ref $x509 eq 'ARRAY' ? :
2656 0 31 unless &Net::SSLeay::CTX_use_certificate($ctx, $cert)
2659 0 1 unless &Net::SSLeay::CTX_add_extra_chain_cert($ctx, $ca)
2666 77 3 if (&Net::SSLeay::CTX_use_certificate_chain_file($ctx, $f)) { }
1 2 elsif (do { push @err, ['PEM', _errstack()]; &Net::SSLeay::CTX_use_certificate_file($ctx, $f, 2) }) { }
2677 1 0 if (not $cert and $arg_hash->{'SSL_passwd_cb'} and defined(my $pw = $arg_hash->{'SSL_passwd_cb'}->(0)))
2682 0 2 unless &Net::SSLeay::CTX_use_certificate($ctx, $cert)
2690 0 0 unless &Net::SSLeay::CTX_add_extra_chain_cert($ctx, $ca)
2693 0 2 if $key and not &Net::SSLeay::CTX_use_PrivateKey($ctx, $key)
2697 2 0 if $key
2698 2 0 if $cert
2699 2 0 if $key
2703 0 80 unless ($havecert)
2708 0 0 if @e
2714 155 109 if (not $havecert or $havekey) { }
28 81 elsif (my $pkey = $arg_hash->{'SSL_key'}) { }
81 0 elsif (my $f = $arg_hash->{'SSL_key_file'} || ($havecert eq 'PEM' ? $arg_hash->{'SSL_cert_file'} : undef)) { }
2718 0 28 unless &Net::SSLeay::CTX_use_PrivateKey($ctx, $pkey)
2724 81 1 if (&Net::SSLeay::CTX_use_PrivateKey_file($ctx, $f, $ft))
2725 80 1 $ft == 1 ? :
2729 0 81 unless $havekey
2733 0 0 if not $is_server and $can_pha and $havecert and $havekey
2737 89 159 if ($arg_hash->{'SSL_server'})
2739 0 89 if (my $f = $arg_hash->{'SSL_dh_file'}) { }
89 0 elsif (my $dh = $arg_hash->{'SSL_dh'}) { }
2744 0 0 unless $dh
2747 0 0 unless $rv = &Net::SSLeay::CTX_set_tmp_dh($_, $dh)
2750 0 0 unless $rv
2755 0 103 unless &Net::SSLeay::CTX_set_tmp_dh($_, $dh)
2761 89 159 if (my $curve = $arg_hash->{'SSL_ecdh_curve'})
2762 0 89 unless $can_ecdh
2767 0 103 if ($arg_hash->{'SSL_server'} and $curve eq 'auto') { }
0 103 elsif ($set_groups_list) { }
0 103 elsif ($curve =~ /:/) { }
103 0 elsif ($arg_hash->{'SSL_server'}) { }
2768 0 0 if ($can_ecdh eq 'can_auto') { }
0 0 elsif ($can_ecdh eq 'auto') { }
2769 0 0 unless Net::SSLeay::CTX_set_ecdh_auto($_, 1)
2780 0 0 unless &$set_groups_list($_, $curve)
2783 0 0 if $can_ecdh eq "can_auto"
2789 89 14 unless ($curve =~ /^\d+$/)
2795 0 103 unless my $ecdh = &Net::SSLeay::EC_KEY_new_by_curve_name($curve)
2799 0 155 unless &Net::SSLeay::CTX_set_tmp_ecdh($_, $ecdh)
2810 9 239 if (my $fp = $arg_hash->{'SSL_fingerprint'})
2811 2 7 ref $fp ? :
2812 0 11 unless my($algo, $pubkey, $digest) = /^(?:([\w-]+)\$)?(pub\$)?([a-f\d:]+)$/i
2815 0 0 length $digest == 64 ? :
0 0 length $digest == 40 ? :
0 0 length $digest == 32 ? :
2834 2 10 $_->[1] ? :
2861 0 248 if ($^O eq "darwin")
2866 0 0 $vcb ? :
2867 0 0 if ($rv != 1)
2878 150 9 if (not $is_server and $can_ocsp_staple and not $verify_fingerprint)
2882 0 78 unless my $iossl = $SSL_OBJECT{$ssl}
2884 0 78 if ($iossl->[1])
2895 0 78 if ($staple_callback)
2901 77 1 unless ($resp)
2902 0 77 if $IO::Socket::SSL::DEBUG >= 3
2905 0 1 if $IO::Socket::SSL::DEBUG >= 3
2907 0 1 if ($status != Net::SSLeay::OCSP_RESPONSE_STATUS_SUCCESSFUL())
2908 0 0 if $IO::Socket::SSL::DEBUG >= 3
2912 0 1 unless (eval { do { &Net::SSLeay::OCSP_response_verify($ssl, $resp) } })
2913 0 0 if $IO::Socket::SSL::DEBUG >= 3
2920 0 3 unless ($certid)
2921 0 0 if $IO::Socket::SSL::DEBUG >= 3
2926 1 2 if ($status and $status->[2])
2928 1 0 if (not $status->[1]) { }
0 0 elsif ($status->[2]{'statusType'} == Net::SSLeay::V_OCSP_CERTSTATUS_GOOD()) { }
2930 0 1 if $cache
2935 0 0 if $cache
2942 0 0 if $cache
2951 0 1 if ($hard_error) { }
1 0 elsif (@results and $chain[0] == $iossl->peer_certificate) { }
2961 248 0 if (my $cl = $arg_hash->{'SSL_cipher_list'})
2965 0 262 ref $cl ? :
0 262 unless &Net::SSLeay::CTX_set_cipher_list($ctx{$_}, scalar(ref $cl ? $cl->{$_} || $cl->{''} || $DEFAULT_SSL_ARGS{'SSL_cipher_list'} || (next) : $cl))
2969 0 248 if (my $cl = $arg_hash->{'SSL_ciphersuites'})
2970 0 0 unless $can_ciphersuites
2975 0 0 ref $cl ? :
0 0 unless Net::SSLeay::CTX_set_ciphersuites($ctx{$_}, ref $cl ? $cl->{$_} || $cl->{''} || $DEFAULT_SSL_ARGS{'SSL_cipher_list'} || (next) : $cl)
2982 6 242 if (keys %ctx > 1 or not exists $ctx{''})
2983 0 6 unless $can_server_sni
2989 4 15 unless defined $host
2990 0 19 unless (my $snictx = $ctx{lc $host} || $ctx{''})
2991 0 0 if $IO::Socket::SSL::DEBUG > 1
2995 0 19 if $IO::Socket::SSL::DEBUG > 1
2996 9 10 if $snictx != $ctx
3001 0 248 if (my $cb = $arg_hash->{'SSL_create_ctx_callback'})
3009 85 161 $self->{'verify_mode'} ? :
2 246 defined $arg_hash->{'SSL_ocsp_mode'} ? :
3011 0 248 if $IO::Socket::SSL::DEBUG >= 3
3013 0 248 if (my $cache = $arg_hash->{'SSL_session_cache'}) { }
3 245 elsif (my $size = $arg_hash->{'SSL_session_cache_size'}) { }
3021 0 248 if ($self->{'session_cache'} and %sess_cb)
3032 0 0 unless (my $key = $args->{'SSL_session_key'})
3036 0 0 if $IO::Socket::SSL::DEBUG >= 3
3042 0 0 if $IO::Socket::SSL::DEBUG >= 3
3059 246 5 if (my $ctx = $self->{'context'})
3060 0 246 if $IO::Socket::SSL::DEBUG >= 3
3061 246 0 if (not $use_threads or delete $CTX_CREATED_IN_THIS_THREAD{$ctx})
3063 86 160 if ($self->{'verify_mode'})
3064 0 86 if $IO::Socket::SSL::DEBUG >= 3
3067 0 246 if ($self->{'ocsp_error_ref'})
3068 0 0 if $IO::Socket::SSL::DEBUG >= 3
3071 0 246 if $IO::Socket::SSL::DEBUG >= 3
3091 0 3 unless $size > 0
3106 0 16 if $IO::Socket::SSL::DEBUG >= 3
3119 1 0 $key ? :
3123 3 0 if (not $session) { }
0 0 elsif ($v->[0] == $session) { }
3130 1 2 if $v == $head
3132 0 0 $key ? :
0 0 $session ? :
0 1 if $IO::Socket::SSL::DEBUG >= 3
3138 0 3 if $_->[0]
3147 3 13 if ($session)
3150 0 3 if $IO::Socket::SSL::DEBUG >= 3
3151 3 0 if $v->[0] == $session
3153 0 0 if $v == $shead
3156 12 4 if ($v)
3160 0 0 $session ? :
0 0 $v ? :
0 16 if $IO::Socket::SSL::DEBUG >= 3
3173 38 18 if ($$rhead) { }
3187 1 27 if ($self->{'room'} < 0)
3190 0 1 if $l->[0]
3202 0 32 unless $$rhead
3205 8 24 if ($v != $$rhead) { }
12 12 elsif ($v->[$inext] == $v) { }
3209 10 2 if ($inext == 4) { }
3228 0 0 if exists $v2i{$v}
3231 0 0 if $v == $self->{'ghead'}
3241 0 0 if $v == $self->{'ghead'}
3253 0 0 if $v == $shead
3264 6 1 if $v->[0]
3283 2 0 unless my $e = $self->{$id}
3285 0 0 if ($e->{'expire'} and time < $e->{'expire'})
3289 0 0 if ($e->{'nextUpdate'} and time < $e->{'nextUpdate'})
3301 0 2 if ($del > 0)
3323 2 2 unless (my $uri = &Net::SSLeay::P_X509_get_ocsp_uri($cert))
3324 0 2 if $IO::Socket::SSL::DEBUG > 2
3328 0 2 unless (my $certid = eval { do { &Net::SSLeay::OCSP_cert2ids($ssl, $cert) } })
3329 0 0 if $IO::Socket::SSL::DEBUG > 2
3333 2 0 if (not $done = $cache->get($certid)) { }
0 0 elsif ($done->{'hard_error'}) { }
0 0 elsif ($done->{'soft_error'}) { }
3350 0 2 unless %todo
3351 1 1 @soft_error ? :
3376 0 2 if not $todo or $self->{'error'}
3381 0 2 if (not $resp) { }
0 2 elsif (not eval { do { $resp = &Net::SSLeay::d2i_OCSP_RESPONSE($resp) } }) { }
0 2 elsif ((my $status = &Net::SSLeay::OCSP_response_status($resp)) != Net::SSLeay::OCSP_RESPONSE_STATUS_SUCCESSFUL()) { }
0 2 elsif (not eval { do { $req = &Net::SSLeay::d2i_OCSP_REQUEST($todo->{'req'}); &Net::SSLeay::OCSP_response_verify($self->{'ssl'}, $resp, $req) } }) { }
2 0 elsif (my(@result) = &Net::SSLeay::OCSP_response_results($resp, @{$$todo{'ids'};})) { }
3413 0 0 if ($@) { }
3421 0 0 unless @soft_error
3434 2 0 if ($rv->[2]) { }
3436 2 0 if (not $rv->[1]) { }
0 0 elsif ($rv->[2]{'statusType'} == Net::SSLeay::V_OCSP_CERTSTATUS_GOOD()) { }
3459 0 2 if (@miss and @found)
3466 0 0 if $IO::Socket::SSL::DEBUG >= 2
3478 2 0 if $req
3479 0 2 if ($self->{'failhard'})
3483 0 2 if (@soft_error)
3484 0 0 if $self->{'soft_error'}
3487 0 2 if (@hard_error) { }
2 0 elsif (not %{$self->{'todo'};}) { }
3500 0 2 unless eval { do { require HTTP::Tiny } }
3504 0 2 if $IO::Socket::SSL::DEBUG
3509 0 2 if $IO::Socket::SSL::DEBUG
3511 2 0 if defined $self->add_response($uri, $resp->{'success'} && $resp->{'content'})
3515 0 2 if $IO::Socket::SSL::DEBUG >= 2
3650 0 0 unless $IO::Socket::SSL::DEBUG >= 2
3659 0 0 if ($ssl_ver and $content_type != $trace_constants{'SSL3_RT_HEADER'} and $content_type != $trace_constants{'SSL3_RT_INNER_CONTENT_TYPE'})
3672 0 0 $ssl_ver == $trace_constants{'SSL3_VERSION_MAJOR'} && $content_type ? :
3677 0 0 if ($content_type == $trace_constants{'SSL3_RT_CHANGE_CIPHER_SPEC'}) { }
0 0 elsif ($content_type == $trace_constants{'SSL3_RT_ALERT'}) { }
3688 0 0 $direction ? :