Skip to content

Commit 15cec35

Browse files
committed
Check bad cert handling in HttpGetFile.t
We'll use a couple of badssl.com sites currently supported by Google. The docs say they are for manual testing only, but that's essentially what we are doing since we don't normally run internet- connecting tests without manually enabling them. So we'll only hit those sites when a developer is doing something extra to test these features, not when anyone is just installing the Win32 package. The docs also say these sites are subject to change without notice, so if that happens, we may have to look elsewhere.
1 parent 0c02c84 commit 15cec35

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

t/HttpGetFile.t

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ my $english_locale = (Win32::FormatMessage(1) eq "Incorrect function.\r\n");
1818
# We may not always have an internet connection, so don't
1919
# attempt remote connections unless the user has done
2020
# set PERL_WIN32_INTERNET_OK=1
21-
plan tests => $ENV{PERL_WIN32_INTERNET_OK} ? 13 : 7;
21+
plan tests => $ENV{PERL_WIN32_INTERNET_OK} ? 19 : 7;
2222

2323
# On Cygwin the test_harness will invoke additional Win32 APIs that
2424
# will reset the Win32::GetLastError() value, so capture it immediately.
@@ -82,4 +82,20 @@ if ($ENV{PERL_WIN32_INTERNET_OK}) {
8282
ok($sha->hexdigest,
8383
'9d282e2292e67fb2e25422dfb190474e30a38de3',
8484
"downloaded GitHub zip archive has correct digest");
85+
86+
ok(HttpGetFile('https://self-signed.badssl.com/index.html', 'NUL:'),
87+
'',
88+
'Cannot download from site with self-signed cert without ignoring cert errors');
89+
ok($LastError, '12175', "correct code for ERROR_WINHTTP_SECURE_FAILURE with self-signed certificate");
90+
ok(HttpGetFile('https://self-signed.badssl.com/index.html', 'NUL:', 1),
91+
'1',
92+
'Can download from site with self-signed cert using ignore cert errors parameter');
93+
94+
ok(HttpGetFile('https://expired.badssl.com/index.html', 'NUL:'),
95+
'',
96+
'Cannot download from site with expired cert without ignoring cert errors');
97+
ok($LastError, '12175', "correct code for ERROR_WINHTTP_SECURE_FAILURE with expired certificate");
98+
ok(HttpGetFile('https://expired.badssl.com/index.html', 'NUL:', 1),
99+
'1',
100+
'Can download from site with expired cert using ignore cert errors parameter');
85101
}

0 commit comments

Comments
 (0)