-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change verify_SSL default to 1, add ENV var to enable insecure default
- Changes the `verify_SSL` default parameter from `0` to `1` Based on patch by Dominic Hargreaves: https://salsa.debian.org/perl-team/interpreter/perl/-/commit/1490431e40e22052f75a0b3449f1f53cbd27ba92 Fixes CVE-2023-31486 - Add check for `$ENV{PERL_HTTP_TINY_SSL_INSECURE_BY_DEFAULT}` that enables the previous insecure default behaviour if set to `1`. This provides a workaround for users who encounter problems with the new `verify_SSL` default. Example to disable certificate checks: ``` $ PERL_HTTP_TINY_SSL_INSECURE_BY_DEFAULT=1 ./script.pl ``` - Updates to documentation: - Describe changing the verify_SSL value - Describe the escape-hatch environment variable - Remove rationale for not enabling verify_SSL - Add missing certificate search paths - Replace "SSL" with "TLS/SSL" where appropriate - Use "machine-in-the-middle" instead of "man-in-the-middle" - Update `210_live_ssl.t` - Use github.com, cpan.org and badssl.com hosts for checking certificates. - Add self signed snake-oil certificate for checking failures rather than bypassing the `SSL_verify_callback` - Test `verify_SSL` parameter in addition to low level SSL_options - Test that `PERL_HTTP_TINY_SSL_INSECURE_BY_DEFAULT=1` behaves as expected against badssl.com - Added `180_verify_SSL.t` - Test that `verify_SSL` default is `1` - Test that `PERL_HTTP_TINY_SSL_INSECURE_BY_DEFAULT` behaves as expected - Test that using different values for `verify_SSL` and legacy `verify_ssl` doesn't disable cert checks
- Loading branch information
Showing
4 changed files
with
277 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#!perl | ||
|
||
use strict; | ||
use warnings; | ||
use Test::More 0.88; | ||
use lib 't'; | ||
|
||
use HTTP::Tiny; | ||
|
||
delete $ENV{PERL_HTTP_TINY_INSECURE_BY_DEFAULT}; | ||
|
||
{ | ||
my $ht = HTTP::Tiny->new(); | ||
is($ht->verify_SSL, 1, "verify_SSL is 1 by default"); | ||
} | ||
|
||
{ | ||
my $ht = HTTP::Tiny->new( | ||
verify_SSL => 0 | ||
); | ||
is($ht->verify_SSL, 0, "verify_SSL=>0 sets 0"); | ||
} | ||
|
||
{ | ||
my $ht = HTTP::Tiny->new( | ||
verify_ssl => 0 | ||
); | ||
is($ht->verify_SSL, 0, "verify_ssl=>0 sets 0"); | ||
} | ||
|
||
{ | ||
my $ht = HTTP::Tiny->new( | ||
verify_SSL => 1, | ||
verify_ssl => 0 | ||
); | ||
is($ht->verify_SSL, 1, "verify_SSL=>1 and verify_ssl=>0 sets 1"); | ||
} | ||
|
||
{ | ||
my $ht = HTTP::Tiny->new( | ||
verify_SSL => 0, | ||
verify_ssl => 1 | ||
); | ||
is($ht->verify_SSL, 1, "verify_SSL=>0 and verify_ssl=>1 sets 1"); | ||
} | ||
|
||
{ | ||
my $ht = HTTP::Tiny->new( | ||
verify_SSL => 0, | ||
verify_ssl => 0 | ||
); | ||
is($ht->verify_SSL, 0, "verify_SSL=>0 and verify_ssl=>0 sets 0"); | ||
} | ||
|
||
{ | ||
local $ENV{PERL_HTTP_TINY_INSECURE_BY_DEFAULT} = "1"; | ||
my $ht = HTTP::Tiny->new(); | ||
is($ht->verify_SSL, 0, "PERL_HTTP_TINY_INSECURE_BY_DEFAULT=1 changes verify_SSL default to 0"); | ||
} | ||
|
||
{ | ||
local $ENV{PERL_HTTP_TINY_INSECURE_BY_DEFAULT} = "0"; | ||
my $ht = HTTP::Tiny->new(); | ||
is($ht->verify_SSL, 1, "PERL_HTTP_TINY_INSECURE_BY_DEFAULT=0 keeps verify_SSL default at 1"); | ||
} | ||
|
||
{ | ||
local $ENV{PERL_HTTP_TINY_INSECURE_BY_DEFAULT} = "False"; | ||
my $ht = HTTP::Tiny->new(); | ||
is($ht->verify_SSL, 1, "Unsupported PERL_HTTP_TINY_INSECURE_BY_DEFAULT=False keeps verify_SSL default at 1"); | ||
} | ||
|
||
{ | ||
local $ENV{PERL_HTTP_TINY_INSECURE_BY_DEFAULT} = "1"; | ||
my $ht = HTTP::Tiny->new(verify_SSL=>1); | ||
is($ht->verify_SSL, 1, "PERL_HTTP_TINY_INSECURE_BY_DEFAULT=1 does not override verify_SSL attribute set to 1"); | ||
} | ||
|
||
{ | ||
local $ENV{PERL_HTTP_TINY_INSECURE_BY_DEFAULT} = "1"; | ||
my $ht = HTTP::Tiny->new( | ||
verify_SSL => 1, | ||
verify_ssl => 1 | ||
); | ||
is($ht->verify_SSL, 1, "PERL_HTTP_TINY_INSECURE_BY_DEFAULT=1, verify_SSL=>1 and verify_ssl=>1 sets 1"); | ||
} | ||
|
||
{ | ||
local $ENV{PERL_HTTP_TINY_INSECURE_BY_DEFAULT} = "1"; | ||
my $ht = HTTP::Tiny->new( | ||
verify_SSL => 1, | ||
verify_ssl => 0 | ||
); | ||
is($ht->verify_SSL, 1, "PERL_HTTP_TINY_INSECURE_BY_DEFAULT=1, verify_SSL=>1 and verify_ssl=>0 sets 1"); | ||
} | ||
|
||
{ | ||
local $ENV{PERL_HTTP_TINY_INSECURE_BY_DEFAULT} = "1"; | ||
my $ht = HTTP::Tiny->new( | ||
verify_SSL => 0, | ||
verify_ssl => 0 | ||
); | ||
is($ht->verify_SSL, 0, "PERL_HTTP_TINY_INSECURE_BY_DEFAULT=1, verify_SSL=>0 and verify_ssl=>0 sets 0"); | ||
} | ||
|
||
|
||
|
||
done_testing; | ||
|
Oops, something went wrong.