Skip to content

Commit 59c617e

Browse files
committed
HTTP::Tiny: import trial v0.083 from CPAN
This is the last bit before v5.38.0, changing the default SSL verification behavior for HTTP::Tiny.
1 parent 059aeb7 commit 59c617e

File tree

9 files changed

+747
-34
lines changed

9 files changed

+747
-34
lines changed

MANIFEST

+7
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,10 @@ cpan/HTTP-Tiny/corpus/redirect-07.txt
12331233
cpan/HTTP-Tiny/corpus/redirect-08.txt
12341234
cpan/HTTP-Tiny/corpus/redirect-09.txt
12351235
cpan/HTTP-Tiny/corpus/redirect-10.txt
1236+
cpan/HTTP-Tiny/corpus/snake-oil.crt
12361237
cpan/HTTP-Tiny/lib/HTTP/Tiny.pm
1238+
cpan/HTTP-Tiny/t/00-report-prereqs.dd
1239+
cpan/HTTP-Tiny/t/00-report-prereqs.t
12371240
cpan/HTTP-Tiny/t/000_load.t
12381241
cpan/HTTP-Tiny/t/001_api.t
12391242
cpan/HTTP-Tiny/t/002_croakage.t
@@ -1260,6 +1263,10 @@ cpan/HTTP-Tiny/t/160_cookies.t
12601263
cpan/HTTP-Tiny/t/161_basic_auth.t
12611264
cpan/HTTP-Tiny/t/162_proxy_auth.t
12621265
cpan/HTTP-Tiny/t/170_keepalive.t
1266+
cpan/HTTP-Tiny/t/180_verify_SSL.t
1267+
cpan/HTTP-Tiny/t/200_live.t
1268+
cpan/HTTP-Tiny/t/200_live_local_ip.t
1269+
cpan/HTTP-Tiny/t/210_live_ssl.t
12631270
cpan/HTTP-Tiny/t/BrokenCookieJar.pm
12641271
cpan/HTTP-Tiny/t/SimpleCookieJar.pm
12651272
cpan/HTTP-Tiny/t/Util.pm

cpan/HTTP-Tiny/corpus/snake-oil.crt

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Generated with:
2+
3+
openssl req -new -newkey rsa:4096 -x509 -new -nodes -sha256 -days 7300 -keyout /dev/null -out snake-oil.crt -subj '/CN=snake.oil/'
4+
5+
-----BEGIN C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wQFMAMBAf8wDQYJKoZI
22+
hvcNAQELBQADggIBAHGiT2h0SU2tlFmUQ8CzgJ7JRTg91ltRwEvs/SQ/YN7DdDwt
23+
dQy/0nMIeFstdDIkdQyjcAUO92msLzd8AniiwAjynxamiQqdA57+rdhp7oEbFgw+
24+
nF56bG4tiBG1gAIxtY9f2sG/Sqf6UuimxOX43nybG8RdRu8hOh/TQXcj8raa2PMT
25+
pTdphjMJUKSplHtFpbLFuf5FxklpeAYxYAReMzQhVgTzi7fcz3QhT/l6eqK6G05v
26+
gi+QsgesMiGdHKiTtx8N70JFZ+8BzJ0CJDI8PR2XZTLbpKxNfk426hTjJBkRULT5
27+
s7IWuuEO4Bb1p27K2WgHGh0mxFk4POPFmotxupVqzl8g2umcfWLDq0UR3BcRyR3B
28+
GWZNCcDTVLaAsarbSJoY1L/6j4O0RQdgpOWiENLbEcelGprGLBVe4s/NDA6aUYA+
29+
2Dll+0tHe6oKI+RCRoDhhiAH7UVIGQdORzcbY3Fxbf1OlFdpOyXLI751b1DjSYRu
30+
9cVFXZIBRTTiEvGbUfoDEXDmKxpWHkGRel2864FBodcwGv7yW6mC3o6vpOqQFcW7
31+
MjJsFhtVj8PdPmue+ye766PeH45ydDD01nr1I92w6E1C0pEEqRNEpoOGgORyNgit
32+
EZag4DlWFs5MFdlj32haztRgi2dhVuJxlzx4lAmvOoqvGVQVIicN1JSlikBk
33+
-----END CERTIFICATE-----

cpan/HTTP-Tiny/lib/HTTP/Tiny.pm

+71-34
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use strict;
44
use warnings;
55
# ABSTRACT: A small, simple, correct HTTP/1.1 client
66

7-
our $VERSION = '0.082';
7+
our $VERSION = '0.083'; # TRIAL
88

99
sub _croak { require Carp; Carp::croak(@_) }
1010

@@ -40,10 +40,15 @@ sub _croak { require Carp; Carp::croak(@_) }
4040
#pod * C<timeout> — Request timeout in seconds (default is 60) If a socket open,
4141
#pod read or write takes longer than the timeout, the request response status code
4242
#pod will be 599.
43-
#pod * C<verify_SSL> — A boolean that indicates whether to validate the SSL
44-
#pod certificate of an C<https> — connection (default is false)
43+
#pod * C<verify_SSL> — A boolean that indicates whether to validate the TLS/SSL
44+
#pod certificate of an C<https> — connection (default is true). Changed from false
45+
#pod to true in version 0.083.
4546
#pod * C<SSL_options> — A hashref of C<SSL_*> — options to pass through to
4647
#pod L<IO::Socket::SSL>
48+
#pod * C<$ENV{PERL_HTTP_TINY_SSL_INSECURE_BY_DEFAULT}> - Changes the default
49+
#pod certificate verification behavior to not check server identity if set to 1.
50+
#pod Only effective if C<verify_SSL> is not set. Added in version 0.083.
51+
#pod
4752
#pod
4853
#pod An accessor/mutator method exists for each attribute.
4954
#pod
@@ -111,11 +116,17 @@ sub timeout {
111116
sub new {
112117
my($class, %args) = @_;
113118

119+
# Support lower case verify_ssl argument, but only if verify_SSL is not
120+
# true.
121+
if ( exists $args{verify_ssl} ) {
122+
$args{verify_SSL} ||= $args{verify_ssl};
123+
}
124+
114125
my $self = {
115126
max_redirect => 5,
116127
timeout => defined $args{timeout} ? $args{timeout} : 60,
117128
keep_alive => 1,
118-
verify_SSL => $args{verify_SSL} || $args{verify_ssl} || 0, # no verification by default
129+
verify_SSL => defined $args{verify_SSL} ? $args{verify_SSL} : _verify_SSL_default(),
119130
no_proxy => $ENV{no_proxy},
120131
};
121132

@@ -134,6 +145,13 @@ sub new {
134145
return $self;
135146
}
136147

148+
sub _verify_SSL_default {
149+
my ($self) = @_;
150+
# Check if insecure default certificate verification behaviour has been
151+
# changed by the user by setting PERL_HTTP_TINY_SSL_INSECURE_BY_DEFAULT=1
152+
return (($ENV{PERL_HTTP_TINY_INSECURE_BY_DEFAULT} || '') eq '1') ? 0 : 1;
153+
}
154+
137155
sub _set_proxies {
138156
my ($self) = @_;
139157

@@ -1060,7 +1078,7 @@ sub new {
10601078
timeout => 60,
10611079
max_line_size => 16384,
10621080
max_header_lines => 64,
1063-
verify_SSL => 0,
1081+
verify_SSL => HTTP::Tiny::_verify_SSL_default(),
10641082
SSL_options => {},
10651083
%args
10661084
}, $class;
@@ -1709,7 +1727,7 @@ HTTP::Tiny - A small, simple, correct HTTP/1.1 client
17091727
17101728
=head1 VERSION
17111729
1712-
version 0.082
1730+
version 0.083
17131731
17141732
=head1 SYNOPSIS
17151733
@@ -1802,12 +1820,16 @@ C<timeout> — Request timeout in seconds (default is 60) If a socket open, read
18021820
18031821
=item *
18041822
1805-
C<verify_SSL> — A boolean that indicates whether to validate the SSL certificate of an C<https> — connection (default is false)
1823+
C<verify_SSL> — A boolean that indicates whether to validate the TLS/SSL certificate of an C<https> — connection (default is true). Changed from false to true in version 0.083.
18061824
18071825
=item *
18081826
18091827
C<SSL_options> — A hashref of C<SSL_*> — options to pass through to L<IO::Socket::SSL>
18101828
1829+
=item *
1830+
1831+
C<$ENV{PERL_HTTP_TINY_SSL_INSECURE_BY_DEFAULT}> - Changes the default certificate verification behavior to not check server identity if set to 1. Only effective if C<verify_SSL> is not set. Added in version 0.083.
1832+
18111833
=back
18121834
18131835
An accessor/mutator method exists for each attribute.
@@ -2052,19 +2074,19 @@ proxy
20522074
timeout
20532075
verify_SSL
20542076
2055-
=head1 SSL SUPPORT
2077+
=head1 TLS/SSL SUPPORT
20562078
20572079
Direct C<https> connections are supported only if L<IO::Socket::SSL> 1.56 or
20582080
greater and L<Net::SSLeay> 1.49 or greater are installed. An error will occur
2059-
if new enough versions of these modules are not installed or if the SSL
2081+
if new enough versions of these modules are not installed or if the TLS
20602082
encryption fails. You can also use C<HTTP::Tiny::can_ssl()> utility function
20612083
that returns boolean to see if the required modules are installed.
20622084
20632085
An C<https> connection may be made via an C<http> proxy that supports the CONNECT
20642086
command (i.e. RFC 2817). You may not proxy C<https> via a proxy that itself
20652087
requires C<https> to communicate.
20662088
2067-
SSL provides two distinct capabilities:
2089+
TLS/SSL provides two distinct capabilities:
20682090
20692091
=over 4
20702092
@@ -2078,34 +2100,25 @@ Verification of server identity
20782100
20792101
=back
20802102
2081-
B<By default, HTTP::Tiny does not verify server identity>.
2103+
B<By default, HTTP::Tiny verifies server identity>.
20822104
2083-
Server identity verification is controversial and potentially tricky because it
2084-
depends on a (usually paid) third-party Certificate Authority (CA) trust model
2085-
to validate a certificate as legitimate. This discriminates against servers
2086-
with self-signed certificates or certificates signed by free, community-driven
2087-
CA's such as L<CAcert.org|http://cacert.org>.
2105+
This was changed in version 0.083 due to security concerns. The previous default
2106+
behavior can be enabled by setting C<$ENV{PERL_HTTP_TINY_SSL_INSECURE_BY_DEFAULT}>
2107+
to 1.
20882108
2089-
By default, HTTP::Tiny does not make any assumptions about your trust model,
2090-
threat level or risk tolerance. It just aims to give you an encrypted channel
2091-
when you need one.
2092-
2093-
Setting the C<verify_SSL> attribute to a true value will make HTTP::Tiny verify
2094-
that an SSL connection has a valid SSL certificate corresponding to the host
2095-
name of the connection and that the SSL certificate has been verified by a CA.
2096-
Assuming you trust the CA, this will protect against a L<man-in-the-middle
2097-
attack|http://en.wikipedia.org/wiki/Man-in-the-middle_attack>. If you are
2098-
concerned about security, you should enable this option.
2109+
Verification is done by checking that that the TLS/SSL connection has a valid
2110+
certificate corresponding to the host name of the connection and that the
2111+
certificate has been verified by a CA. Assuming you trust the CA, this will
2112+
protect against L<machine-in-the-middle
2113+
attacks|http://en.wikipedia.org/wiki/Machine-in-the-middle_attack>.
20992114
21002115
Certificate verification requires a file containing trusted CA certificates.
21012116
21022117
If the environment variable C<SSL_CERT_FILE> is present, HTTP::Tiny
21032118
will try to find a CA certificate file in that location.
21042119
21052120
If the L<Mozilla::CA> module is installed, HTTP::Tiny will use the CA file
2106-
included with it as a source of trusted CA's. (This means you trust Mozilla,
2107-
the author of Mozilla::CA, the CPAN mirror where you got Mozilla::CA, the
2108-
toolchain used to install it, and your operating system security, right?)
2121+
included with it as a source of trusted CA's.
21092122
21102123
If that module is not available, then HTTP::Tiny will search several
21112124
system-specific default locations for a CA certificate file:
@@ -2124,13 +2137,33 @@ system-specific default locations for a CA certificate file:
21242137
21252138
/etc/ssl/ca-bundle.pem
21262139
2140+
=item *
2141+
2142+
/etc/openssl/certs/ca-certificates.crt
2143+
2144+
=item *
2145+
2146+
/etc/ssl/cert.pem
2147+
2148+
=item *
2149+
2150+
/usr/local/share/certs/ca-root-nss.crt
2151+
2152+
=item *
2153+
2154+
/etc/pki/tls/cacert.pem
2155+
2156+
=item *
2157+
2158+
/etc/certs/ca-certificates.crt
2159+
21272160
=back
21282161
21292162
An error will be occur if C<verify_SSL> is true and no CA certificate file
21302163
is available.
21312164
2132-
If you desire complete control over SSL connections, the C<SSL_options> attribute
2133-
lets you provide a hash reference that will be passed through to
2165+
If you desire complete control over TLS/SSL connections, the C<SSL_options>
2166+
attribute lets you provide a hash reference that will be passed through to
21342167
C<IO::Socket::SSL::start_SSL()>, overriding any options set by HTTP::Tiny. For
21352168
example, to provide your own trusted CA file:
21362169
@@ -2140,7 +2173,7 @@ example, to provide your own trusted CA file:
21402173
21412174
The C<SSL_options> attribute could also be used for such things as providing a
21422175
client certificate for authentication to a server or controlling the choice of
2143-
cipher used for the SSL connection. See L<IO::Socket::SSL> documentation for
2176+
cipher used for the TLS/SSL connection. See L<IO::Socket::SSL> documentation for
21442177
details.
21452178
21462179
=head1 PROXY SUPPORT
@@ -2346,7 +2379,7 @@ David Golden <[email protected]>
23462379
23472380
=head1 CONTRIBUTORS
23482381
2349-
=for stopwords Alan Gardner Alessandro Ghedini A. Sinan Unur Brad Gilbert brian m. carlson Chris Nehren Weyl Claes Jakobsson Clinton Gormley Craig Berry David Golden Mitchell Dean Pearce Edward Zborowski Felipe Gasper Graham Knop Greg Kennedy James E Keenan Raspass Jeremy Mates Jess Robinson Karen Etheridge Lukas Eklund Martin J. Evans Martin-Louis Bright Matthew Horsfall Michael R. Davis Mike Doherty Nicolas Rochelemagne Olaf Alders Olivier Mengué Petr Písař sanjay-cpu Serguei Trouchelle Shoichi Kaji SkyMarshal Sören Kornetzki Steve Grazzini Syohei YOSHIDA Tatsuhiko Miyagawa Tom Hukins Tony Cook Xavier Guimard
2382+
=for stopwords Alan Gardner Alessandro Ghedini A. Sinan Unur Brad Gilbert brian m. carlson Chris Nehren Weyl Claes Jakobsson Clinton Gormley Craig Berry David Golden Mitchell Dean Pearce Edward Zborowski Felipe Gasper Graham Knop Greg Kennedy James E Keenan Raspass Jeremy Mates Jess Robinson Karen Etheridge Lukas Eklund Martin J. Evans Martin-Louis Bright Matthew Horsfall Michael R. Davis Mike Doherty Nicolas Rochelemagne Olaf Alders Olivier Mengué Petr Písař sanjay-cpu Serguei Trouchelle Shoichi Kaji SkyMarshal Sören Kornetzki Steve Grazzini Stig Palmquist Syohei YOSHIDA Tatsuhiko Miyagawa Tom Hukins Tony Cook Xavier Guimard
23502383
23512384
=over 4
23522385
@@ -2508,6 +2541,10 @@ Steve Grazzini <[email protected]>
25082541
25092542
=item *
25102543
2544+
Stig Palmquist <[email protected]>
2545+
2546+
=item *
2547+
25112548
Syohei YOSHIDA <[email protected]>
25122549
25132550
=item *
@@ -2530,7 +2567,7 @@ Xavier Guimard <[email protected]>
25302567
25312568
=head1 COPYRIGHT AND LICENSE
25322569
2533-
This software is copyright (c) 2022 by Christian Hansen.
2570+
This software is copyright (c) 2023 by Christian Hansen.
25342571
25352572
This is free software; you can redistribute it and/or modify it under
25362573
the same terms as the Perl 5 programming language system itself.

cpan/HTTP-Tiny/t/00-report-prereqs.dd

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
do { my $x = {
2+
'configure' => {
3+
'requires' => {
4+
'ExtUtils::MakeMaker' => '6.17',
5+
'perl' => '5.006'
6+
},
7+
'suggests' => {
8+
'JSON::PP' => '2.27300'
9+
}
10+
},
11+
'develop' => {
12+
'requires' => {
13+
'Dist::Zilla' => '5',
14+
'Dist::Zilla::Plugin::Prereqs' => '0',
15+
'Dist::Zilla::Plugin::ReleaseStatus::FromVersion' => '0',
16+
'Dist::Zilla::Plugin::RemovePrereqs' => '0',
17+
'Dist::Zilla::PluginBundle::DAGOLDEN' => '0.072',
18+
'File::Spec' => '0',
19+
'File::Temp' => '0',
20+
'IO::Handle' => '0',
21+
'IPC::Open3' => '0',
22+
'Perl::Critic::Policy::Lax::ProhibitStringyEval::ExceptForRequire' => '0',
23+
'Pod::Coverage::TrustPod' => '0',
24+
'Pod::Wordlist' => '0',
25+
'Software::License::Perl_5' => '0',
26+
'Test::CPAN::Meta' => '0',
27+
'Test::MinimumVersion' => '0',
28+
'Test::More' => '0',
29+
'Test::Perl::Critic' => '0',
30+
'Test::Pod' => '1.41',
31+
'Test::Pod::Coverage' => '1.08',
32+
'Test::Portability::Files' => '0',
33+
'Test::Spelling' => '0.12',
34+
'Test::Version' => '1',
35+
'perl' => '5.006'
36+
}
37+
},
38+
'runtime' => {
39+
'recommends' => {
40+
'HTTP::CookieJar' => '0.001',
41+
'IO::Socket::IP' => '0.32',
42+
'IO::Socket::SSL' => '1.42',
43+
'Mozilla::CA' => '20160104',
44+
'Net::SSLeay' => '1.49'
45+
},
46+
'requires' => {
47+
'Carp' => '0',
48+
'Fcntl' => '0',
49+
'IO::Socket' => '0',
50+
'MIME::Base64' => '0',
51+
'Socket' => '0',
52+
'Time::Local' => '0',
53+
'bytes' => '0',
54+
'perl' => '5.006',
55+
'strict' => '0',
56+
'warnings' => '0'
57+
},
58+
'suggests' => {
59+
'IO::Socket::SSL' => '1.56'
60+
}
61+
},
62+
'test' => {
63+
'recommends' => {
64+
'CPAN::Meta' => '2.120900'
65+
},
66+
'requires' => {
67+
'Data::Dumper' => '0',
68+
'Exporter' => '0',
69+
'ExtUtils::MakeMaker' => '0',
70+
'File::Basename' => '0',
71+
'File::Spec' => '0',
72+
'File::Temp' => '0',
73+
'IO::Dir' => '0',
74+
'IO::File' => '0',
75+
'IO::Socket::INET' => '0',
76+
'IPC::Cmd' => '0',
77+
'Test::More' => '0.96',
78+
'lib' => '0',
79+
'open' => '0',
80+
'perl' => '5.006'
81+
}
82+
}
83+
};
84+
$x;
85+
}

0 commit comments

Comments
 (0)