Skip to content

Commit 06fe291

Browse files
Merge pull request libwww-perl#4 from dagolden/topic/fix-ssl-verify-mode-warnings
Fix IO::Socket::SSL warnings when not verifying hostname
2 parents 54946d7 + 38dbf2e commit 06fe291

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/LWP/Protocol/https.pm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ sub _extra_sock_opts
1919
$ssl_opts{SSL_verify_mode} ||= 1;
2020
$ssl_opts{SSL_verifycn_scheme} = 'www';
2121
}
22+
else {
23+
$ssl_opts{SSL_verify_mode} = 0;
24+
}
2225
if ($ssl_opts{SSL_verify_mode}) {
2326
unless (exists $ssl_opts{SSL_ca_file} || exists $ssl_opts{SSL_ca_path}) {
2427
eval {

t/apache.t

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,19 @@ use LWP::UserAgent;
88
my $ua = LWP::UserAgent->new();
99
plan skip_all => "Not online" unless $ua->is_online;
1010

11-
plan tests => 2;
11+
plan tests => 4;
12+
1213
my $res = $ua->simple_request(HTTP::Request->new(GET => "https://www.apache.org"));
1314

1415
ok($res->is_success);
1516
like($res->content, qr/Apache Software Foundation/);
1617

18+
# test for RT #81948
19+
my $warn = '';
20+
$SIG{__WARN__} = sub { $warn = shift };
21+
$ua = LWP::UserAgent->new( ssl_opts => {verify_hostname => 0} );
22+
$res = $ua->simple_request(HTTP::Request->new(GET => "https://www.apache.org"));
23+
ok($res->is_success);
24+
is($warn, '', "no warning seen");
25+
1726
$res->dump(prefix => "# ");

0 commit comments

Comments
 (0)