Skip to content

Commit ea2f68c

Browse files
committed
Make TLS enabled proxy work (proxy URL https:// not http://) by using
stacked TLS layers newly introduced in IO::Socket::SSL 2.096
1 parent a235440 commit ea2f68c

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

lib/LWP/Protocol/https.pm

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,26 @@ if ( $Net::HTTPS::SSL_SOCKET_CLASS->can('start_SSL')) {
9999
# SNI should be passed there only if it is not an IP address.
100100
# Details: https://github.com/libwww-perl/libwww-perl/issues/449#issuecomment-1896175509
101101
my $host = $url->host() =~ m/:|^[\d.]+$/s ? undef : $url->host();
102-
$sock = LWP::Protocol::https::Socket->start_SSL( $sock,
102+
my $usebio = {};
103+
if (UNIVERSAL::can($sock,'is_SSL') && $sock->is_SSL) {
104+
$usebio = eval { $Net::HTTPS::SSL_SOCKET_CLASS->can_nested_ssl } or
105+
die "no support for nested TLS in this IO::Socket::SSL version";
106+
}
107+
108+
$sock = LWP::Protocol::https::Socket->start_SSL( my $osock = $sock,
103109
SSL_verifycn_name => $url->host,
104110
SSL_hostname => $host,
111+
%$usebio,
105112
$self->_extra_sock_opts,
106113
);
107-
$@ = LWP::Protocol::https::Socket->errstr if ! $sock;
114+
if (!$sock) {
115+
$@ = LWP::Protocol::https::Socket->errstr;
116+
return;
117+
}
118+
if ($usebio and my @fields = grep { /^http_/ } keys %{*$osock}) {
119+
# propagate any http_ fields from osock to sock
120+
@{*$sock}{@fields} = @{*$osock}{@fields}
121+
}
108122
return $sock;
109123
}
110124
}

0 commit comments

Comments
 (0)