| 1 | package Net::SSL; | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use MIME::Base64; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Socket; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use vars qw(@ISA $VERSION $NEW_ARGS); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 9 | $VERSION = '2.86'; | ||||||||||||||||||||||||||||||||||
| 10 | $VERSION = eval $VERSION; | ||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||
| 12 | require IO::Socket; | ||||||||||||||||||||||||||||||||||
| 13 | @ISA=qw(IO::Socket::INET); | ||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||
| 15 | my %REAL; # private to this package only | ||||||||||||||||||||||||||||||||||
| 16 | my $DEFAULT_VERSION = '23'; | ||||||||||||||||||||||||||||||||||
| 17 | my $CRLF = "\015\012"; | ||||||||||||||||||||||||||||||||||
| 18 | my $SEND_USERAGENT_TO_PROXY = 0; | ||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||
| 20 | require Crypt::SSLeay; | ||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub _default_context { | ||||||||||||||||||||||||||||||||
|
Subroutine
_default_context: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 23 | 0 | require Crypt::SSLeay::MainContext; | |||||||||||||||||||||||||||||||||
| 24 | 0 | Crypt::SSLeay::MainContext::main_ctx(@_); | |||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub _alarm_set { | ||||||||||||||||||||||||||||||||
|
Subroutine
_alarm_set: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | return if $^O eq 'MSWin32' or $^O eq 'NetWare'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$^O eq "MSWin32" or $^O eq "NetWare"
MC/DC0%0/2
$^O eq "MSWin32" or $^O eq "NetWare"
$^O eq "MSWin32"
$^O eq "NetWare"
Truth table0%0/3
A or B
A= $^O eq "MSWin32"B= $^O eq "NetWare"
| |||||||||||||||||||||||||||||||||||
| 29 | 0 | alarm(shift); | |||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 33 | 0 | my($class, %arg) = @_; | |||||||||||||||||||||||||||||||||
| 34 | 0 | local $NEW_ARGS = \%arg; | |||||||||||||||||||||||||||||||||
| 35 | 0 | $class->SUPER::new(%arg); | |||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 39 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 40 | 0 | delete $REAL{$self}; | |||||||||||||||||||||||||||||||||
| 41 | 0 | local $@; | |||||||||||||||||||||||||||||||||
| 42 | 0 | eval { $self->SUPER::DESTROY; }; | |||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | sub configure { | ||||||||||||||||||||||||||||||||
|
Subroutine
configure: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||
| 46 | 0 | my($self, $arg) = @_; | |||||||||||||||||||||||||||||||||
| 47 | my $ssl_version = delete $arg->{SSL_Version} || | ||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | $ENV{HTTPS_VERSION} || $DEFAULT_VERSION; | ||||||||||||||||||||||||||||||||
|
Condition0%0/6
delete $arg->{'SSL_Version'} || $ENV{'HTTPS_VERSION'} || $DEFAULT_VERSION
delete $arg->{"SSL_Version"} or $ENV{"HTTPS_VERSION"}
MC/DC0%0/3
delete $arg->{'SSL_Version'} || $ENV{'HTTPS_VERSION'} || $DEFAULT_VERSION
delete $arg->{"SSL_Version"}
$ENV{"HTTPS_VERSION"}
$DEFAULT_VERSION
Truth table0%0/4
A or B || C
A= delete $arg->{"SSL_Version"}B= $ENV{"HTTPS_VERSION"}C= $DEFAULT_VERSION
| |||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | my $ssl_debug = delete $arg->{SSL_Debug} || $ENV{HTTPS_DEBUG} || 0; | ||||||||||||||||||||||||||||||||
|
Condition0%0/5
delete $arg->{'SSL_Debug'} || $ENV{'HTTPS_DEBUG'} || 0
delete $arg->{"SSL_Debug"} or $ENV{"HTTPS_DEBUG"}
MC/DC0%0/2
delete $arg->{'SSL_Debug'} || $ENV{'HTTPS_DEBUG'} || 0
delete $arg->{"SSL_Debug"}
$ENV{"HTTPS_DEBUG"}
Truth table0%0/3
A or B
A= delete $arg->{"SSL_Debug"}B= $ENV{"HTTPS_DEBUG"}
| |||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | my $ctx = delete $arg->{SSL_Context} || _default_context($ssl_version); | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
delete $arg->{'SSL_Context'} || _default_context($ssl_version)
MC/DC0%0/2
delete $arg->{'SSL_Context'} || _default_context($ssl_version)
delete $arg->{'SSL_Context'}
_default_context($ssl_version)
Truth table0%0/3
A || B
A= delete $arg->{'SSL_Context'}B= _default_context($ssl_version)
| |||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||
| 53 | 0 | *$self->{ssl_ctx} = $ctx; | |||||||||||||||||||||||||||||||||
| 54 | 0 | *$self->{ssl_version} = $ssl_version; | |||||||||||||||||||||||||||||||||
| 55 | 0 | *$self->{ssl_debug} = $ssl_debug; | |||||||||||||||||||||||||||||||||
| 56 | 0 | *$self->{ssl_arg} = $arg; | |||||||||||||||||||||||||||||||||
| 57 | 0 | *$self->{ssl_peer_addr} = $arg->{PeerAddr}; | |||||||||||||||||||||||||||||||||
| 58 | 0 | *$self->{ssl_peer_port} = $arg->{PeerPort}; | |||||||||||||||||||||||||||||||||
| 59 | 0 | *$self->{ssl_new_arg} = $NEW_ARGS; | |||||||||||||||||||||||||||||||||
| 60 | 0 | *$self->{ssl_peer_verify} = 0; | |||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||
| 62 | ## Crypt::SSLeay must also aware the SSL Proxy before calling | ||||||||||||||||||||||||||||||||||
| 63 | ## $socket->configure($args). Because the $sock->configure() will | ||||||||||||||||||||||||||||||||||
| 64 | ## die when failed to resolve the destination server IP address, | ||||||||||||||||||||||||||||||||||
| 65 | ## whether the SSL proxy is used or not! | ||||||||||||||||||||||||||||||||||
| 66 | ## - dqbai, 2003-05-10 | ||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | if (my $proxy = $self->proxy) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 68 | 0 | ($arg->{PeerAddr}, $arg->{PeerPort}) = split(':',$proxy); | |||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | $arg->{PeerPort} || croak("no port given for proxy server $proxy"); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||
| 72 | 0 | $self->SUPER::configure($arg); | |||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||
| 75 | # override to make sure there is really a timeout | ||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | sub timeout { | ||||||||||||||||||||||||||||||||
|
Subroutine
timeout: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | shift->SUPER::timeout || 60; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | sub blocking { | ||||||||||||||||||||||||||||||||
|
Subroutine
blocking: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 81 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 82 | 0 | $self->SUPER::blocking(@_); | |||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | sub connect { | ||||||||||||||||||||||||||||||||
|
Subroutine
connect: not called CC=16 SCAR=56.1
| |||||||||||||||||||||||||||||||||||
| 86 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||
| 88 | # configure certs on connect() time, so we can throw an undef | ||||||||||||||||||||||||||||||||||
| 89 | # and have LWP understand the error | ||||||||||||||||||||||||||||||||||
| 90 | 0 | eval { $self->configure_certs() }; | |||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | if($@) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 92 | 0 | $@ = "configure certs failed: $@; $!"; | |||||||||||||||||||||||||||||||||
| 93 | 0 | $self->die_with_error($@); | |||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||
| 96 | # finished, update set_verify status | ||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if(my $rv = *$self->{ssl_ctx}->set_verify()) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 98 | 0 | *$self->{ssl_peer_verify} = $rv; | |||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | if ($self->proxy) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 102 | # don't die() in connect, just return undef and set $@ | ||||||||||||||||||||||||||||||||||
| 103 | 0 | my $proxy_connect = eval { $self->proxy_connect_helper(@_) }; | |||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | if(! $proxy_connect || $@) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $proxy_connect or $@
MC/DC0%0/2
not $proxy_connect or $@
not $proxy_connect
$@
Truth table0%0/3
not(A) or B
A= not $proxy_connectB= $@
| |||||||||||||||||||||||||||||||||||
| 105 | 0 | $@ = "proxy connect failed: $@; $!"; | |||||||||||||||||||||||||||||||||
| 106 | 0 | croak($@); | |||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||
| 109 | else { | ||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | *$self->{io_socket_peername}=@_ == 1 ? $_[0] : IO::Socket::sockaddr_in(@_); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | if(!$self->SUPER::connect(@_)) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 112 | # better to die than return here | ||||||||||||||||||||||||||||||||||
| 113 | 0 | $@ = "Connect failed: $@; $!"; | |||||||||||||||||||||||||||||||||
| 114 | 0 | croak($@); | |||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | my $debug = *$self->{ssl_debug} || 0; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
*$self->{'ssl_debug'} || 0
MC/DC0%0/1
*$self->{'ssl_debug'} || 0
*$self->{'ssl_debug'}
Truth table0%0/2
A
A= *$self->{'ssl_debug'}
| |||||||||||||||||||||||||||||||||||
| 119 | 0 | my $ssl = Crypt::SSLeay::Conn->new(*$self->{ssl_ctx}, $debug, $self); | |||||||||||||||||||||||||||||||||
| 120 | 0 | my $arg = *$self->{ssl_arg}; | |||||||||||||||||||||||||||||||||
| 121 | 0 | my $new_arg = *$self->{ssl_new_arg}; | |||||||||||||||||||||||||||||||||
| 122 | 0 | $arg->{SSL_Debug} = $debug; | |||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||
| 124 | # setup SNI if available | ||||||||||||||||||||||||||||||||||
| 125 | $ssl->can("set_tlsext_host_name") and | ||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | $ssl->set_tlsext_host_name(*$self->{ssl_peer_addr}); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||
| 128 | 0 | eval { | |||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | local $SIG{ALRM} = sub { $self->die_with_error("SSL connect timeout") }; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 130 | # timeout / 2 because we have 3 possible connects here | ||||||||||||||||||||||||||||||||||
| 131 | 0 | _alarm_set($self->timeout / 2); | |||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||
| 133 | 0 | my $rv; | |||||||||||||||||||||||||||||||||
| 134 | { | ||||||||||||||||||||||||||||||||||
| 135 | 0 | local $SIG{PIPE} = \¨ | |||||||||||||||||||||||||||||||||
| 136 | 0 | $rv = eval { $ssl->connect; }; | |||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | if (not defined $rv or $rv <= 0) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $rv or $rv <= 0
MC/DC0%0/2
not defined $rv or $rv <= 0
not defined $rv
$rv <= 0
Truth table0%0/3
not(A) or B
A= not defined $rvB= $rv <= 0
| |||||||||||||||||||||||||||||||||||
| 139 | 0 | _alarm_set(0); | |||||||||||||||||||||||||||||||||
| 140 | 0 | $ssl = undef; | |||||||||||||||||||||||||||||||||
| 141 | # See RT #59312 | ||||||||||||||||||||||||||||||||||
| 142 | 0 | my %args = (%$arg, %$new_arg); | |||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | if(*$self->{ssl_version} == 23) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 144 | 0 | $args{SSL_Version} = 3; | |||||||||||||||||||||||||||||||||
| 145 | # the new connect might itself be overridden with a REAL SSL | ||||||||||||||||||||||||||||||||||
| 146 | 0 | my $new_ssl = Net::SSL->new(%args); | |||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | $REAL{$self} = $REAL{$new_ssl} || $new_ssl; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$REAL{$new_ssl} || $new_ssl
MC/DC0%0/2
$REAL{$new_ssl} || $new_ssl
$REAL{$new_ssl}
$new_ssl
Truth table0%0/3
A || B
A= $REAL{$new_ssl}B= $new_ssl
| |||||||||||||||||||||||||||||||||||
| 148 | 0 | return $REAL{$self}; | |||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||
| 150 | elsif(*$self->{ssl_version} == 3) { | ||||||||||||||||||||||||||||||||||
| 151 | # $self->die_with_error("SSL negotiation failed"); | ||||||||||||||||||||||||||||||||||
| 152 | 0 | $args{SSL_Version} = 2; | |||||||||||||||||||||||||||||||||
| 153 | 0 | my $new_ssl = Net::SSL->new(%args); | |||||||||||||||||||||||||||||||||
| 154 | 0 | $REAL{$self} = $new_ssl; | |||||||||||||||||||||||||||||||||
| 155 | 0 | return $new_ssl; | |||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||
| 157 | else { | ||||||||||||||||||||||||||||||||||
| 158 | # don't die, but do set $@, and return undef | ||||||||||||||||||||||||||||||||||
| 159 | 0 | eval { $self->die_with_error("SSL negotiation failed") }; | |||||||||||||||||||||||||||||||||
| 160 | 0 | croak($@); | |||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||
| 163 | 0 | _alarm_set(0); | |||||||||||||||||||||||||||||||||
| 164 | }; | ||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||
| 166 | # odd error in eval {} block, maybe alarm outside the evals | ||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | if($@) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 168 | 0 | $@ = "$@; $!"; | |||||||||||||||||||||||||||||||||
| 169 | 0 | croak($@); | |||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||
| 172 | # successful SSL connection gets stored | ||||||||||||||||||||||||||||||||||
| 173 | 0 | *$self->{ssl_ssl} = $ssl; | |||||||||||||||||||||||||||||||||
| 174 | 0 | $self; | |||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||
| 177 | # Delegate these calls to the Crypt::SSLeay::Conn object | ||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | sub get_peer_certificate { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_peer_certificate: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 179 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | $self = $REAL{$self} || $self; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$REAL{$self} || $self
MC/DC0%0/2
$REAL{$self} || $self
$REAL{$self}
$self
Truth table0%0/3
A || B
A= $REAL{$self}B= $self
| |||||||||||||||||||||||||||||||||||
| 181 | 0 | *$self->{ssl_ssl}->get_peer_certificate(@_); | |||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | sub get_peer_verify { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_peer_verify: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 185 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | $self = $REAL{$self} || $self; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$REAL{$self} || $self
MC/DC0%0/2
$REAL{$self} || $self
$REAL{$self}
$self
Truth table0%0/3
A || B
A= $REAL{$self}B= $self
| |||||||||||||||||||||||||||||||||||
| 187 | 0 | *$self->{ssl_peer_verify}; | |||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | sub get_shared_ciphers { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_shared_ciphers: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 191 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | $self = $REAL{$self} || $self; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$REAL{$self} || $self
MC/DC0%0/2
$REAL{$self} || $self
$REAL{$self}
$self
Truth table0%0/3
A || B
A= $REAL{$self}B= $self
| |||||||||||||||||||||||||||||||||||
| 193 | 0 | *$self->{ssl_ssl}->get_shared_ciphers(@_); | |||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | sub get_cipher { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_cipher: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 197 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | $self = $REAL{$self} || $self; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$REAL{$self} || $self
MC/DC0%0/2
$REAL{$self} || $self
$REAL{$self}
$self
Truth table0%0/3
A || B
A= $REAL{$self}B= $self
| |||||||||||||||||||||||||||||||||||
| 199 | 0 | *$self->{ssl_ssl}->get_cipher(@_); | |||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | sub pending { | ||||||||||||||||||||||||||||||||
|
Subroutine
pending: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 203 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | $self = $REAL{$self} || $self; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$REAL{$self} || $self
MC/DC0%0/2
$REAL{$self} || $self
$REAL{$self}
$self
Truth table0%0/3
A || B
A= $REAL{$self}B= $self
| |||||||||||||||||||||||||||||||||||
| 205 | 0 | *$self->{ssl_ssl}->pending(@_); | |||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | sub ssl_context { | ||||||||||||||||||||||||||||||||
|
Subroutine
ssl_context: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 209 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | $self = $REAL{$self} || $self; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$REAL{$self} || $self
MC/DC0%0/2
$REAL{$self} || $self
$REAL{$self}
$self
Truth table0%0/3
A || B
A= $REAL{$self}B= $self
| |||||||||||||||||||||||||||||||||||
| 211 | 0 | *$self->{ssl_ctx}; | |||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | sub die_with_error { | ||||||||||||||||||||||||||||||||
|
Subroutine
die_with_error: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 215 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||
| 216 | 0 | my $reason=shift; | |||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||
| 218 | 0 | my @err; | |||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | while(my $err=Crypt::SSLeay::Err::get_error_string()) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 220 | 0 | push @err, $err; | |||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||
| 222 | 0 | croak("$reason: " . join( ' | ', @err )); | |||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | sub read { | ||||||||||||||||||||||||||||||||
|
Subroutine
read: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 226 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | $self = $REAL{$self} || $self; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$REAL{$self} || $self
MC/DC0%0/2
$REAL{$self} || $self
$REAL{$self}
$self
Truth table0%0/3
A || B
A= $REAL{$self}B= $self
| |||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||
| 229 | 0 | local $SIG{__DIE__} = \&Carp::confess; | |||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | local $SIG{ALRM} = sub { $self->die_with_error("SSL read timeout") }; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||
| 232 | 0 | _alarm_set($self->timeout); | |||||||||||||||||||||||||||||||||
| 233 | 0 | my $n = *$self->{ssl_ssl}->read(@_); | |||||||||||||||||||||||||||||||||
| 234 | 0 | _alarm_set(0); | |||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | $self->die_with_error("read failed") if !defined $n; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||
| 237 | 0 | $n; | |||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | sub write { | ||||||||||||||||||||||||||||||||
|
Subroutine
write: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 241 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | $self = $REAL{$self} || $self; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$REAL{$self} || $self
MC/DC0%0/2
$REAL{$self} || $self
$REAL{$self}
$self
Truth table0%0/3
A || B
A= $REAL{$self}B= $self
| |||||||||||||||||||||||||||||||||||
| 243 | 0 | my $n = *$self->{ssl_ssl}->write(@_); | |||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | $self->die_with_error("write failed") if !defined $n; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 245 | 0 | $n; | |||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||
| 248 | *sysread = \&read; | ||||||||||||||||||||||||||||||||||
| 249 | *syswrite = \&write; | ||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | sub print { | ||||||||||||||||||||||||||||||||
|
Subroutine
print: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 252 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | $self = $REAL{$self} || $self; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$REAL{$self} || $self
MC/DC0%0/2
$REAL{$self} || $self
$REAL{$self}
$self
Truth table0%0/3
A || B
A= $REAL{$self}B= $self
| |||||||||||||||||||||||||||||||||||
| 254 | # should we care about $, and $\?? | ||||||||||||||||||||||||||||||||||
| 255 | # I think it is too expensive... | ||||||||||||||||||||||||||||||||||
| 256 | 0 | $self->write(join("", @_)); | |||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | sub printf { | ||||||||||||||||||||||||||||||||
|
Subroutine
printf: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 260 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | $self = $REAL{$self} || $self; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$REAL{$self} || $self
MC/DC0%0/2
$REAL{$self} || $self
$REAL{$self}
$self
Truth table0%0/3
A || B
A= $REAL{$self}B= $self
| |||||||||||||||||||||||||||||||||||
| 262 | 0 | my $fmt = shift; | |||||||||||||||||||||||||||||||||
| 263 | 0 | $self->write(sprintf($fmt, @_)); | |||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | sub getchunk { | ||||||||||||||||||||||||||||||||
|
Subroutine
getchunk: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 267 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | $self = $REAL{$self} || $self; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$REAL{$self} || $self
MC/DC0%0/2
$REAL{$self} || $self
$REAL{$self}
$self
Truth table0%0/3
A || B
A= $REAL{$self}B= $self
| |||||||||||||||||||||||||||||||||||
| 269 | 0 | my $buf = ''; # warnings | |||||||||||||||||||||||||||||||||
| 270 | 0 | my $n = $self->read($buf, 32768); | |||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | return unless defined $n; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 272 | 0 | $buf; | |||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||
| 275 | # This is really inefficient, but we only use it for reading the proxy response | ||||||||||||||||||||||||||||||||||
| 276 | # so that does not really matter. | ||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | sub getline { | ||||||||||||||||||||||||||||||||
|
Subroutine
getline: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 278 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | $self = $REAL{$self} || $self; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$REAL{$self} || $self
MC/DC0%0/2
$REAL{$self} || $self
$REAL{$self}
$self
Truth table0%0/3
A || B
A= $REAL{$self}B= $self
| |||||||||||||||||||||||||||||||||||
| 280 | 0 | my $val=""; | |||||||||||||||||||||||||||||||||
| 281 | 0 | my $buf; | |||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | do { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 283 | 0 | $self->SUPER::recv($buf, 1); | |||||||||||||||||||||||||||||||||
| 284 | 0 | $val .= $buf; | |||||||||||||||||||||||||||||||||
| 285 | } until ($buf eq "\n"); | ||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||
| 287 | 0 | $val; | |||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||
| 290 | # XXX: no way to disable <$sock>?? (tied handle perhaps?) | ||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | sub get_lwp_object { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_lwp_object: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||
| 293 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||
| 295 | 0 | my $lwp_object; | |||||||||||||||||||||||||||||||||
| 296 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||||
| 297 | 0 | while(1) { | |||||||||||||||||||||||||||||||||
| 298 | package DB; | ||||||||||||||||||||||||||||||||||
| 299 | 0 | my @stack = caller($i++); | |||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | last unless @stack; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 301 | 0 | my @stack_args = @DB::args; | |||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | my $stack_object = $stack_args[0] || next; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$stack_args[0] || (next)
MC/DC0%0/1
$stack_args[0] || (next)
$stack_args[0]
Truth table0%0/2
A
A= $stack_args[0]
| |||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | return $stack_object | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $stack_object and $stack_object->isa("LWP::UserAgent")
MC/DC0%0/2
ref $stack_object and $stack_object->isa("LWP::UserAgent")
ref $stack_object
$stack_object->isa("LWP::UserAgent")
Truth table0%0/3
A and B
A= ref $stack_objectB= $stack_object->isa("LWP::UserAgent")
| |||||||||||||||||||||||||||||||||||
| 304 | if ref($stack_object) | ||||||||||||||||||||||||||||||||||
| 305 | and $stack_object->isa('LWP::UserAgent'); | ||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||
| 307 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | sub send_useragent_to_proxy { | ||||||||||||||||||||||||||||||||
|
Subroutine
send_useragent_to_proxy: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | if (my $val = shift) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 312 | 0 | $SEND_USERAGENT_TO_PROXY = $val; | |||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||
| 314 | 0 | return $SEND_USERAGENT_TO_PROXY; | |||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | sub proxy_connect_helper { | ||||||||||||||||||||||||||||||||
|
Subroutine
proxy_connect_helper: not called CC=23 SCAR=63.1
| |||||||||||||||||||||||||||||||||||
| 318 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||
| 320 | 0 | my $proxy = $self->proxy; | |||||||||||||||||||||||||||||||||
| 321 | 0 | my ($proxy_host, $proxy_port) = split(':',$proxy); | |||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | $proxy_port || croak("no port given for proxy server $proxy"); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||
| 324 | 0 | my $proxy_addr = gethostbyname($proxy_host); | |||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | $proxy_addr || croak("can't resolve proxy server name: $proxy_host, $!"); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||
| 327 | 0 | my($peer_port, $peer_addr) = (*$self->{ssl_peer_port}, *$self->{ssl_peer_addr}); | |||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | $peer_addr || croak("no peer addr given"); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | $peer_port || croak("no peer port given"); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||
| 331 | # see if the proxy should be bypassed | ||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | my @no_proxy = split( /\s*,\s*/, $ENV{NO_PROXY} || $ENV{no_proxy} || ''); | ||||||||||||||||||||||||||||||||
|
Condition0%0/5
$ENV{'NO_PROXY'} || $ENV{'no_proxy'} || ''
$ENV{"NO_PROXY"} or $ENV{"no_proxy"}
MC/DC0%0/2
$ENV{'NO_PROXY'} || $ENV{'no_proxy'} || ''
$ENV{"NO_PROXY"}
$ENV{"no_proxy"}
Truth table0%0/3
A or B
A= $ENV{"NO_PROXY"}B= $ENV{"no_proxy"}
| |||||||||||||||||||||||||||||||||||
| 333 | 0 | my $is_proxied = 1; | |||||||||||||||||||||||||||||||||
| 334 | 0 | my $domain; | |||||||||||||||||||||||||||||||||
| 335 | 0 | for $domain (@no_proxy) { | |||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | if ($peer_addr =~ /\Q$domain\E$/) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 337 | 0 | $is_proxied = 0; | |||||||||||||||||||||||||||||||||
| 338 | 0 | last; | |||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | if ($is_proxied) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | $self->SUPER::connect($proxy_port, $proxy_addr) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 344 | || croak("proxy connect to $proxy_host:$proxy_port failed: $!"); | ||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||
| 346 | else { | ||||||||||||||||||||||||||||||||||
| 347 | # see RT #57836 | ||||||||||||||||||||||||||||||||||
| 348 | 0 | my $peer_addr_packed = gethostbyname($peer_addr); | |||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | $self->SUPER::connect($peer_port, $peer_addr_packed) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 350 | || croak("proxy bypass to $peer_addr:$peer_addr failed: $!"); | ||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||
| 353 | 0 | my $connect_string; | |||||||||||||||||||||||||||||||||
| 354 | 0 | ▶ | if ($ENV{"HTTPS_PROXY_USERNAME"} || $ENV{"HTTPS_PROXY_PASSWORD"}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ENV{"HTTPS_PROXY_USERNAME"} or $ENV{"HTTPS_PROXY_PASSWORD"}
MC/DC0%0/2
$ENV{"HTTPS_PROXY_USERNAME"} or $ENV{"HTTPS_PROXY_PASSWORD"}
$ENV{"HTTPS_PROXY_USERNAME"}
$ENV{"HTTPS_PROXY_PASSWORD"}
Truth table0%0/3
A or B
A= $ENV{"HTTPS_PROXY_USERNAME"}B= $ENV{"HTTPS_PROXY_PASSWORD"}
| |||||||||||||||||||||||||||||||||||
| 355 | 0 | my $user = $ENV{"HTTPS_PROXY_USERNAME"}; | |||||||||||||||||||||||||||||||||
| 356 | 0 | my $pass = $ENV{"HTTPS_PROXY_PASSWORD"}; | |||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||
| 358 | 0 | my $credentials = encode_base64("$user:$pass", ""); | |||||||||||||||||||||||||||||||||
| 359 | 0 | $connect_string = join($CRLF, | |||||||||||||||||||||||||||||||||
| 360 | "CONNECT $peer_addr:$peer_port HTTP/1.0", | ||||||||||||||||||||||||||||||||||
| 361 | "Proxy-authorization: Basic $credentials" | ||||||||||||||||||||||||||||||||||
| 362 | ); | ||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||
| 364 | else { | ||||||||||||||||||||||||||||||||||
| 365 | 0 | $connect_string = "CONNECT $peer_addr:$peer_port HTTP/1.0"; | |||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||
| 367 | 0 | $connect_string .= $CRLF; | |||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | if (send_useragent_to_proxy()) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 370 | 0 | my $lwp_object = $self->get_lwp_object; | |||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | if($lwp_object && $lwp_object->agent) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$lwp_object and $lwp_object->agent
MC/DC0%0/2
$lwp_object and $lwp_object->agent
$lwp_object
$lwp_object->agent
Truth table0%0/3
A and B
A= $lwp_objectB= $lwp_object->agent
| |||||||||||||||||||||||||||||||||||
| 372 | 0 | $connect_string .= "User-Agent: ".$lwp_object->agent.$CRLF; | |||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||
| 376 | 0 | $connect_string .= $CRLF; | |||||||||||||||||||||||||||||||||
| 377 | 0 | $self->SUPER::send($connect_string); | |||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||
| 379 | 0 | my $timeout; | |||||||||||||||||||||||||||||||||
| 380 | 0 | my $header = ''; | |||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||
| 382 | # See RT #33954 | ||||||||||||||||||||||||||||||||||
| 383 | # See also RT #64054 | ||||||||||||||||||||||||||||||||||
| 384 | # Handling incomplete reads and writes better (for some values of | ||||||||||||||||||||||||||||||||||
| 385 | # better) may actually make this problem go away, but either way, | ||||||||||||||||||||||||||||||||||
| 386 | # there is no good reason to use \d when checking for 0-9 | ||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | while ($header !~ m{HTTP/[0-9][.][0-9]\s+200\s+.*$CRLF$CRLF}s) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | $timeout = $self->timeout(5) unless length $header; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 390 | 0 | my $n = $self->SUPER::sysread($header, 8192, length $header); | |||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | last if $n <= 0; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | $self->timeout($timeout) if defined $timeout; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | my $conn_ok = ($header =~ m{HTTP/[0-9]+[.][0-9]+\s+200\s+}is) ? 1 : 0; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | if (not $conn_ok) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 398 | 0 | croak("PROXY ERROR HEADER, could be non-SSL URL:\n$header"); | |||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||
| 401 | 0 | $conn_ok; | |||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||
| 404 | # code adapted from LWP::UserAgent, with $ua->env_proxy API | ||||||||||||||||||||||||||||||||||
| 405 | # see also RT #57836 | ||||||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | sub proxy { | ||||||||||||||||||||||||||||||||
|
Subroutine
proxy: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||
| 407 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | my $proxy_server = $ENV{HTTPS_PROXY} || $ENV{https_proxy}; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ENV{'HTTPS_PROXY'} || $ENV{'https_proxy'}
MC/DC0%0/2
$ENV{'HTTPS_PROXY'} || $ENV{'https_proxy'}
$ENV{'HTTPS_PROXY'}
$ENV{'https_proxy'}
Truth table0%0/3
A || B
A= $ENV{'HTTPS_PROXY'}B= $ENV{'https_proxy'}
| |||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | return unless $proxy_server; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||
| 411 | my($peer_port, $peer_addr) = ( | ||||||||||||||||||||||||||||||||||
| 412 | *$self->{ssl_peer_port}, | ||||||||||||||||||||||||||||||||||
| 413 | *$self->{ssl_peer_addr} | ||||||||||||||||||||||||||||||||||
| 414 | 0 | ); | |||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | $peer_addr || croak("no peer addr given"); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | $peer_port || croak("no peer port given"); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||
| 418 | # see if the proxy should be bypassed | ||||||||||||||||||||||||||||||||||
| 419 | my @no_proxy = split( /\s*,\s*/, | ||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | $ENV{NO_PROXY} || $ENV{no_proxy} || '' | ||||||||||||||||||||||||||||||||
|
Condition0%0/5
$ENV{'NO_PROXY'} || $ENV{'no_proxy'} || ''
$ENV{"NO_PROXY"} or $ENV{"no_proxy"}
MC/DC0%0/2
$ENV{'NO_PROXY'} || $ENV{'no_proxy'} || ''
$ENV{"NO_PROXY"}
$ENV{"no_proxy"}
Truth table0%0/3
A or B
A= $ENV{"NO_PROXY"}B= $ENV{"no_proxy"}
| |||||||||||||||||||||||||||||||||||
| 421 | ); | ||||||||||||||||||||||||||||||||||
| 422 | 0 | my $is_proxied = 1; | |||||||||||||||||||||||||||||||||
| 423 | 0 | for my $domain (@no_proxy) { | |||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | if ($peer_addr =~ /\Q$domain\E\z/) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 425 | 0 | return; | |||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||
| 429 | 0 | $proxy_server =~ s|\Ahttps?://||i; | |||||||||||||||||||||||||||||||||
| 430 | # sanitize the end of the string too | ||||||||||||||||||||||||||||||||||
| 431 | # see also http://www.nntp.perl.org/group/perl.libwww/2012/10/msg7629.html | ||||||||||||||||||||||||||||||||||
| 432 | # and https://github.com/nanis/Crypt-SSLeay/pull/1 | ||||||||||||||||||||||||||||||||||
| 433 | # Thank you Mark Allen and YigangX Wen | ||||||||||||||||||||||||||||||||||
| 434 | 0 | $proxy_server =~ s|(:[1-9][0-9]{0,4})/\z|$1|; | |||||||||||||||||||||||||||||||||
| 435 | 0 | $proxy_server; | |||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | sub configure_certs { | ||||||||||||||||||||||||||||||||
|
Subroutine
configure_certs: not called CC=13 SCAR=52.0
| |||||||||||||||||||||||||||||||||||
| 439 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 440 | 0 | my $ctx = *$self->{ssl_ctx}; | |||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||
| 442 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||
| 443 | 0 | for (qw(HTTPS_PKCS12_FILE HTTPS_CERT_FILE HTTPS_KEY_FILE)) { | |||||||||||||||||||||||||||||||||
| 444 | 0 | my $file = $ENV{$_}; | |||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | if ($file) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | (-e $file) or croak("$file file does not exist: $!"); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 447 | 0 | ▶ | (-r $file) or croak("$file file is not readable"); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 448 | 0 | $count++; | |||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | if (/PKCS12/) { | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 450 | 0 | $count++; | |||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | $ctx->use_pkcs12_file($file ,$ENV{'HTTPS_PKCS12_PASSWORD'}) || croak("failed to load $file: $!"); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 452 | 0 | last; | |||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||
| 454 | elsif (/CERT/) { | ||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | $ctx->use_certificate_file($file ,1) || croak("failed to load $file: $!"); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||
| 457 | elsif (/KEY/) { | ||||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | $ctx->use_PrivateKey_file($file, 1) || croak("failed to load $file: $!"); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||
| 460 | else { | ||||||||||||||||||||||||||||||||||
| 461 | 0 | croak("setting $_ not supported"); | |||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||
| 466 | # if both configs are set, then verify them | ||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | if ($count == 2) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | if (! $ctx->check_private_key) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 469 | 0 | croak("Private key and certificate do not match"); | |||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||
| 473 | 0 | $count; # number of successful cert loads/checks | |||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | sub accept { shift->_unimpl("accept") } | ||||||||||||||||||||||||||||||||
|
Subroutine
accept: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | sub getc { shift->_unimpl("getc") } | ||||||||||||||||||||||||||||||||
|
Subroutine
getc: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | sub ungetc { shift->_unimpl("ungetc") } | ||||||||||||||||||||||||||||||||
|
Subroutine
ungetc: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | sub getlines { shift->_unimpl("getlines"); } | ||||||||||||||||||||||||||||||||
|
Subroutine
getlines: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | sub _unimpl { | ||||||||||||||||||||||||||||||||
|
Subroutine
_unimpl: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 482 | 0 | my($self, $meth) = @_; | |||||||||||||||||||||||||||||||||
| 483 | 0 | croak("$meth not implemented for Net::SSL sockets"); | |||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||
| 486 | 1; | ||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||
| 488 | __END__ | ||||||||||||||||||||||||||||||||||