mirror of
https://github.com/mirror/wget.git
synced 2025-01-28 05:10:35 +08:00
Fix path and VPATH issues of new https/TLS tests
* tests/SSLTest.pm: Use $srcdir in read-only files, (_setup_server): Remove unneeded path fixation code * tests/Test-https-*.px: Use $srcdir for read-only files, use $cdir for writable files * tests/certs/interca.conf: Adjust paths * tests/certs/rootca.conf: Adjust paths
This commit is contained in:
parent
466afc62b0
commit
b5c2d083ea
@ -10,10 +10,17 @@ use HTTPTest;
|
||||
our @ISA = qw(WgetTest HTTPTest);
|
||||
my $VERSION = 0.01;
|
||||
|
||||
my $srcdir;
|
||||
if (defined $ENV{srcdir}) {
|
||||
$srcdir = Cwd::abs_path($ENV{srcdir});
|
||||
} else {
|
||||
$srcdir = ".";
|
||||
}
|
||||
|
||||
my %ssl_defaults = (
|
||||
_certfile => "certs/server.crt",
|
||||
_keyfile => "certs/server.key",
|
||||
_cafile => "certs/test-ca-cert.pem",
|
||||
_certfile => "$srcdir/certs/server.crt",
|
||||
_keyfile => "$srcdir/certs/server.key",
|
||||
_cafile => "$srcdir/certs/test-ca-cert.pem",
|
||||
_ciphers => 'ALL',
|
||||
_lhostname => 'wgettestingserver',
|
||||
_sslport => 55443,
|
||||
@ -49,15 +56,15 @@ sub _setup_server
|
||||
my ($argname) = ($attrname =~ m/^_(.*)/msx);
|
||||
$ssl_config{$argname} = $self->{$attrname};
|
||||
}
|
||||
for my $attrname (keys %ssl_config)
|
||||
{
|
||||
if ($attrname =~ m/file$/)
|
||||
{
|
||||
my $cwd = $self->SUPER::_default_for('_workdir');
|
||||
my $cfile = $ssl_config{$attrname};
|
||||
$ssl_config{$attrname} = "$cwd/$cfile";
|
||||
}
|
||||
}
|
||||
# for my $attrname (keys %ssl_config)
|
||||
# {
|
||||
# if ($attrname =~ m/file$/ && !$attrname =~ m/^\//)
|
||||
# {
|
||||
# my $cwd = $self->SUPER::_default_for('_workdir');
|
||||
# my $cfile = $ssl_config{$attrname};
|
||||
# $ssl_config{$attrname} = "$cwd/$cfile";
|
||||
# }
|
||||
# }
|
||||
$self->{_server}->init(%ssl_config);
|
||||
}
|
||||
|
||||
|
@ -28,45 +28,56 @@ unless ($ossl =~ m/OpenSSL 1/)
|
||||
exit 77;
|
||||
}
|
||||
|
||||
my $cdir = $ENV{'PWD'};
|
||||
my $srcdir;
|
||||
if (@ARGV) {
|
||||
$srcdir = shift @ARGV;
|
||||
} elsif (defined $ENV{srcdir}) {
|
||||
$srcdir = $ENV{srcdir};
|
||||
}
|
||||
$srcdir = Cwd::abs_path("$srcdir");
|
||||
|
||||
my $cdir = $ENV{'PWD'};
|
||||
# HOSTALIASES env variable allows us to create hosts file alias.
|
||||
my $testhostname = "WgetTestingServer";
|
||||
$ENV{'HOSTALIASES'} = "$cdir/certs/wgethosts";
|
||||
|
||||
my $addr = gethostbyname($testhostname) or
|
||||
my $addr = gethostbyname($testhostname);
|
||||
unless ($addr)
|
||||
{
|
||||
warn "Failed to resolve $addr, using $srcdir/certs/wgethosts\n";
|
||||
exit 77;
|
||||
}
|
||||
unless (inet_ntoa($addr) =~ "127.0.0.1")
|
||||
{
|
||||
warn "Failed to resolve $testhostname";
|
||||
warn "Failed to resolve $$addr, using $srcdir/certs/wgethosts\n";
|
||||
exit 77;
|
||||
}
|
||||
|
||||
# Create certindex
|
||||
open CERTID, ">", "$cdir/certs/certindex" or
|
||||
warn "Cannot overwrite file $cdir/certs/certindex";
|
||||
open CERTID, ">", "$cdir/certindex" or
|
||||
warn "Cannot overwrite file $cdir/certindex";
|
||||
close CERTID;
|
||||
|
||||
# Create certserial
|
||||
open CERTSN, ">", "$cdir/certs/certserial" or
|
||||
warn "Cannot overwrite file $cdir/certs/certserial";
|
||||
open CERTSN, ">", "$cdir/certserial" or
|
||||
warn "Cannot overwrite file $cdir/certserial";
|
||||
print CERTSN "1122";
|
||||
close CERTSN;
|
||||
|
||||
# Create crlnumber
|
||||
open CRLN, ">", "$cdir/certs/crlnumber" or
|
||||
warn "Cannot overwrite file $cdir/certs/crlnumber";
|
||||
open CRLN, ">", "$cdir/crlnumber" or
|
||||
warn "Cannot overwrite file $cdir/crlnumber";
|
||||
print CRLN "1122";
|
||||
close CRLN;
|
||||
|
||||
my $caconf = "$cdir/certs/rootca.conf";
|
||||
my $cacrt = "$cdir/certs/test-ca-cert.pem";
|
||||
my $cakey = "$cdir/certs/test-ca-key.pem";
|
||||
my $caconf = "$srcdir/certs/rootca.conf";
|
||||
my $cacrt = "$srcdir/certs/test-ca-cert.pem";
|
||||
my $cakey = "$srcdir/certs/test-ca-key.pem";
|
||||
|
||||
# Prepare expired server certificate
|
||||
my $servercrt = "certs/tmpserver3.crt";
|
||||
my $serverkey = "certs/tmpserver3.key";
|
||||
my $servercsr = "$cdir/certs/tmpserver3.csr";
|
||||
my $servercrt = "$cdir/tmpserver3.crt";
|
||||
my $serverkey = "$cdir/tmpserver3.key";
|
||||
my $servercsr = "$cdir/tmpserver3.csr";
|
||||
my $enddate = strftime "%y%m%d%H%M%S%z", localtime(time-86400);
|
||||
my $startdate = strftime "%y%m%d%H%M%S%z", localtime(time+86400);
|
||||
my $serversubj = "/C=US/ST=CA/L=Server Mystery Spot/O=Serv/CN=".
|
||||
|
@ -27,44 +27,55 @@ unless ($ossl =~ m/OpenSSL 1/)
|
||||
exit 77;
|
||||
}
|
||||
|
||||
my $cdir = $ENV{'PWD'};
|
||||
my $srcdir;
|
||||
if (@ARGV) {
|
||||
$srcdir = shift @ARGV;
|
||||
} elsif (defined $ENV{srcdir}) {
|
||||
$srcdir = $ENV{srcdir};
|
||||
}
|
||||
$srcdir = Cwd::abs_path("$srcdir");
|
||||
|
||||
my $cdir = $ENV{'PWD'};
|
||||
# HOSTALIASES env variable allows us to create hosts file alias.
|
||||
my $testhostname = "WgetTestingServer";
|
||||
$ENV{'HOSTALIASES'} = "$cdir/certs/wgethosts";
|
||||
$ENV{'HOSTALIASES'} = "$srcdir/certs/wgethosts";
|
||||
|
||||
my $addr = gethostbyname($testhostname) or
|
||||
my $addr = gethostbyname($testhostname);
|
||||
unless ($addr)
|
||||
{
|
||||
warn "Failed to resolve $addr, using $srcdir/certs/wgethosts\n";
|
||||
exit 77;
|
||||
}
|
||||
unless (inet_ntoa($addr) =~ "127.0.0.1")
|
||||
{
|
||||
warn "Failed to resolve $testhostname";
|
||||
warn "Failed to resolve $$addr, using $srcdir/certs/wgethosts\n";
|
||||
exit 77;
|
||||
}
|
||||
|
||||
# Create certindex
|
||||
open CERTID, ">", "$cdir/certs/certindex" or
|
||||
warn "Cannot overwrite file $cdir/certs/certindex";
|
||||
open CERTID, ">", "$cdir/certindex" or
|
||||
warn "Cannot overwrite file $cdir/certindex";
|
||||
close CERTID;
|
||||
|
||||
# Create certserial
|
||||
open CERTSN, ">", "$cdir/certs/certserial" or
|
||||
warn "Cannot overwrite file $cdir/certs/certserial";
|
||||
open CERTSN, ">", "$cdir/certserial" or
|
||||
warn "Cannot overwrite file $cdir/certserial";
|
||||
print CERTSN "1122";
|
||||
close CERTSN;
|
||||
|
||||
# Create crlnumber
|
||||
open CRLN, ">", "$cdir/certs/crlnumber" or
|
||||
warn "Cannot overwrite file $cdir/certs/crlnumber";
|
||||
open CRLN, ">", "$cdir/crlnumber" or
|
||||
warn "Cannot overwrite file $cdir/crlnumber";
|
||||
close CRLN;
|
||||
|
||||
my $caconf = "$cdir/certs/rootca.conf";
|
||||
my $cacrt = "$cdir/certs/test-ca-cert.pem";
|
||||
my $cakey = "$cdir/certs/test-ca-key.pem";
|
||||
my $caconf = "$srcdir/certs/rootca.conf";
|
||||
my $cacrt = "$srcdir/certs/test-ca-cert.pem";
|
||||
my $cakey = "$srcdir/certs/test-ca-key.pem";
|
||||
|
||||
# Prepare server certificate
|
||||
my $servercrt = "certs/tmpserver1.crt";
|
||||
my $serverkey = "certs/tmpserver1.key";
|
||||
my $servercsr = "$cdir/certs/tmpserver.csr";
|
||||
my $servercrt = "$cdir/tmpserver1.crt";
|
||||
my $serverkey = "$cdir/tmpserver1.key";
|
||||
my $servercsr = "$cdir/tmpserver.csr";
|
||||
my $serversubj = "/C=US/ST=CA/L=Server Mystery Spot/O=Serv/CN=".
|
||||
"$testhostname/emailAddress=servertester";
|
||||
my $servercmd = "openssl genrsa -out $serverkey 4096 && openssl req -new".
|
||||
@ -84,9 +95,9 @@ unless(-e $servercrt && -e $serverkey && $servercheck == 1)
|
||||
}
|
||||
|
||||
# Prepare client certificate
|
||||
my $clientcert = "$cdir/certs/client.crt";
|
||||
my $clientkey = "$cdir/certs/client.key";
|
||||
my $clientcsr = "$cdir/certs/client.csr";
|
||||
my $clientcert = "$cdir/client.crt";
|
||||
my $clientkey = "$cdir/client.key";
|
||||
my $clientcsr = "$cdir/client.csr";
|
||||
my $clientsubj = "/C=US/ST=CA/L=Client Mystery Spot/O=Client/CN=".
|
||||
"Client Tester/emailAddress=clienttester";
|
||||
my $clientcertcmd = "openssl genrsa -out $clientkey 4096 &&".
|
||||
|
@ -27,45 +27,56 @@ unless ($ossl =~ m/OpenSSL 1/)
|
||||
exit 77;
|
||||
}
|
||||
|
||||
my $cdir = $ENV{'PWD'};
|
||||
my $srcdir;
|
||||
if (@ARGV) {
|
||||
$srcdir = shift @ARGV;
|
||||
} elsif (defined $ENV{srcdir}) {
|
||||
$srcdir = $ENV{srcdir};
|
||||
}
|
||||
$srcdir = Cwd::abs_path("$srcdir");
|
||||
|
||||
my $cdir = $ENV{'PWD'};
|
||||
# HOSTALIASES env variable allows us to create hosts file alias.
|
||||
my $testhostname = "WgetTestingServer";
|
||||
$ENV{'HOSTALIASES'} = "$cdir/certs/wgethosts";
|
||||
$ENV{'HOSTALIASES'} = "$srcdir/certs/wgethosts";
|
||||
|
||||
my $addr = gethostbyname($testhostname) or
|
||||
my $addr = gethostbyname($testhostname);
|
||||
unless ($addr)
|
||||
{
|
||||
warn "Failed to resolve $addr, using $srcdir/certs/wgethosts\n";
|
||||
exit 77;
|
||||
}
|
||||
unless (inet_ntoa($addr) =~ "127.0.0.1")
|
||||
{
|
||||
warn "Failed to resolve $testhostname";
|
||||
warn "Failed to resolve $$addr, using $srcdir/certs/wgethosts\n";
|
||||
exit 77;
|
||||
}
|
||||
|
||||
# Create certindex
|
||||
open CERTID, ">", "$cdir/certs/certindex" or
|
||||
warn "Cannot overwrite file $cdir/certs/certindex";
|
||||
open CERTID, ">", "$cdir/certindex" or
|
||||
warn "Cannot overwrite file $cdir/certindex";
|
||||
close CERTID;
|
||||
|
||||
# Create certserial
|
||||
open CERTSN, ">", "$cdir/certs/certserial" or
|
||||
warn "Cannot overwrite file $cdir/certs/certserial";
|
||||
open CERTSN, ">", "$cdir/certserial" or
|
||||
warn "Cannot overwrite file $cdir/certserial";
|
||||
print CERTSN "1122";
|
||||
close CERTSN;
|
||||
|
||||
# Create crlnumber
|
||||
open CRLN, ">", "$cdir/certs/crlnumber" or
|
||||
warn "Cannot overwrite file $cdir/certs/crlnumber";
|
||||
open CRLN, ">", "$cdir/crlnumber" or
|
||||
warn "Cannot overwrite file $cdir/crlnumber";
|
||||
print CRLN "1122";
|
||||
close CRLN;
|
||||
|
||||
my $caconf = "$cdir/certs/rootca.conf";
|
||||
my $cacrt = "$cdir/certs/test-ca-cert.pem";
|
||||
my $cakey = "$cdir/certs/test-ca-key.pem";
|
||||
my $caconf = "$srcdir/certs/rootca.conf";
|
||||
my $cacrt = "$srcdir/certs/test-ca-cert.pem";
|
||||
my $cakey = "$srcdir/certs/test-ca-key.pem";
|
||||
|
||||
# Prepare server certificate
|
||||
my $servercrt = "certs/tmpserver2.crt";
|
||||
my $serverkey = "certs/tmpserver2.key";
|
||||
my $servercsr = "$cdir/certs/tmpserver.csr";
|
||||
my $servercrt = "$cdir/tmpserver2.crt";
|
||||
my $serverkey = "$cdir/tmpserver2.key";
|
||||
my $servercsr = "$cdir/tmpserver.csr";
|
||||
my $serversubj = "/C=US/ST=CA/L=Server Mystery Spot/O=Serv/CN=".
|
||||
"$testhostname/emailAddress=servertester";
|
||||
my $servercmd = "openssl genrsa -out $serverkey 4096 && openssl req -new".
|
||||
@ -114,7 +125,7 @@ if ($sslsock->run() != 0)
|
||||
}
|
||||
|
||||
# Revoke the certificate
|
||||
my $crlfile = "$cdir/certs/servercrl.pem";
|
||||
my $crlfile = "$cdir/servercrl.pem";
|
||||
my $revokecmd = "openssl ca -config $caconf -revoke $servercrt &&
|
||||
openssl ca -config $caconf -gencrl -keyfile $cakey ".
|
||||
"-cert $cacrt -out $crlfile";
|
||||
@ -127,7 +138,7 @@ unless(-e $crlfile)
|
||||
}
|
||||
|
||||
# To read a CRL file use the following command:
|
||||
# openssl crl -text -in certs/root.crl.pem
|
||||
# openssl crl -text -in $srcdir/certs/root.crl.pem
|
||||
|
||||
# Retry the test with CRL. Expect Failure.
|
||||
$port = 23443;
|
||||
|
@ -27,22 +27,34 @@ unless ($ossl =~ m/OpenSSL 1/)
|
||||
exit 77;
|
||||
}
|
||||
|
||||
my $srcdir;
|
||||
if (@ARGV) {
|
||||
$srcdir = shift @ARGV;
|
||||
} elsif (defined $ENV{srcdir}) {
|
||||
$srcdir = $ENV{srcdir};
|
||||
}
|
||||
$srcdir = Cwd::abs_path("$srcdir");
|
||||
|
||||
my $cdir = $ENV{'PWD'};
|
||||
# HOSTALIASES env variable allows us to create hosts file alias.
|
||||
my $testhostname = "WgetTestingServer";
|
||||
$ENV{'HOSTALIASES'} = "$cdir/certs/wgethosts";
|
||||
$ENV{'HOSTALIASES'} = "$srcdir/certs/wgethosts";
|
||||
|
||||
my $addr = gethostbyname($testhostname) or
|
||||
my $addr = gethostbyname($testhostname);
|
||||
unless ($addr)
|
||||
{
|
||||
warn "Failed to resolve $addr, using $srcdir/certs/wgethosts\n";
|
||||
exit 77;
|
||||
}
|
||||
unless (inet_ntoa($addr) =~ "127.0.0.1")
|
||||
{
|
||||
warn "Failed to resolve $testhostname";
|
||||
warn "Failed to resolve $$addr, using $srcdir/certs/wgethosts\n";
|
||||
exit 77;
|
||||
}
|
||||
|
||||
my $port = 24443;
|
||||
my $cmdline = $WgetTest::WGETPATH . " --secure-protocol=PFS".
|
||||
" --ca-certificate=$cdir/certs/test-ca-cert.pem".
|
||||
" --ca-certificate=$srcdir/certs/test-ca-cert.pem".
|
||||
" https://$testhostname:$port/somefile.txt";
|
||||
|
||||
my $expected_error_code = 0;
|
||||
|
@ -27,23 +27,34 @@ unless ($ossl =~ m/OpenSSL 1/)
|
||||
exit 77;
|
||||
}
|
||||
|
||||
my $cdir = $ENV{'PWD'};
|
||||
my $srcdir;
|
||||
if (@ARGV) {
|
||||
$srcdir = shift @ARGV;
|
||||
} elsif (defined $ENV{srcdir}) {
|
||||
$srcdir = $ENV{srcdir};
|
||||
}
|
||||
$srcdir = Cwd::abs_path("$srcdir");
|
||||
|
||||
my $cdir = $ENV{'PWD'};
|
||||
# HOSTALIASES env variable allows us to create hosts file alias.
|
||||
my $testhostname = "WgetTestingServer";
|
||||
$ENV{'HOSTALIASES'} = "$cdir/certs/wgethosts";
|
||||
$ENV{'HOSTALIASES'} = "$srcdir/certs/wgethosts";
|
||||
|
||||
my $addr = gethostbyname($testhostname) or
|
||||
my $addr = gethostbyname($testhostname);
|
||||
unless ($addr)
|
||||
{
|
||||
warn "Failed to resolve $addr, using $srcdir/certs/wgethosts\n";
|
||||
exit 77;
|
||||
}
|
||||
unless (inet_ntoa($addr) =~ "127.0.0.1")
|
||||
{
|
||||
warn "Failed to resolve $testhostname";
|
||||
warn "Failed to resolve $$addr, using $srcdir/certs/wgethosts\n";
|
||||
exit 77;
|
||||
}
|
||||
|
||||
# Prepare self-signed certificates
|
||||
my $certfile="tmpsscert.pem";
|
||||
my $keyfile="tmpsskey.pem";
|
||||
my $certfile="$cdir/tmpsscert.pem";
|
||||
my $keyfile="$cdir/tmpsskey.pem";
|
||||
my $certsubj="/C=US/ST=CA/L=Mystery Spot/O=Dis/CN=$testhostname/emailAddress=tester";
|
||||
my $sscertcmd="openssl req -x509 -nodes -newkey rsa:4096 -keyout $keyfile ".
|
||||
" -out $certfile -days 365 -subj \"$certsubj\"";
|
||||
@ -61,7 +72,7 @@ unless(-e $certfile && -e $keyfile && $sscheck == 1)
|
||||
|
||||
# Try Wget using SSL first without --no-check-certificate. expect error
|
||||
my $port = 26443;
|
||||
my $cmdline = $WgetTest::WGETPATH . " --ca-certificate=$cdir/certs/test-ca-cert.pem".
|
||||
my $cmdline = $WgetTest::WGETPATH . " --ca-certificate=$srcdir/certs/test-ca-cert.pem".
|
||||
" https://$testhostname:$port/somefile.txt";
|
||||
my $expected_error_code = 5;
|
||||
my %existing_files = (
|
||||
@ -90,7 +101,7 @@ if ($sslsock->run() == 0)
|
||||
# Retry the test with --no-check-certificate. expect success
|
||||
$port = 27443;
|
||||
$cmdline = $WgetTest::WGETPATH . " --no-check-certificate ".
|
||||
" --ca-certificate=$cdir/certs/test-ca-cert.pem".
|
||||
" --ca-certificate=$srcdir/certs/test-ca-cert.pem".
|
||||
" https://$testhostname:$port/somefile.txt";
|
||||
|
||||
$expected_error_code = 0;
|
||||
|
@ -27,22 +27,34 @@ unless ($ossl =~ m/OpenSSL 1/)
|
||||
exit 77;
|
||||
}
|
||||
|
||||
my $srcdir;
|
||||
if (@ARGV) {
|
||||
$srcdir = shift @ARGV;
|
||||
} elsif (defined $ENV{srcdir}) {
|
||||
$srcdir = $ENV{srcdir};
|
||||
}
|
||||
$srcdir = Cwd::abs_path("$srcdir");
|
||||
|
||||
my $cdir = $ENV{'PWD'};
|
||||
# HOSTALIASES env variable allows us to create hosts file alias.
|
||||
my $testhostname = "WgetTestingServer";
|
||||
$ENV{'HOSTALIASES'} = "$cdir/certs/wgethosts";
|
||||
$ENV{'HOSTALIASES'} = "$srcdir/certs/wgethosts";
|
||||
|
||||
my $addr = gethostbyname($testhostname) or
|
||||
my $addr = gethostbyname($testhostname);
|
||||
unless ($addr)
|
||||
{
|
||||
warn "Failed to resolve $addr, using $srcdir/certs/wgethosts\n";
|
||||
exit 77;
|
||||
}
|
||||
unless (inet_ntoa($addr) =~ "127.0.0.1")
|
||||
{
|
||||
warn "Failed to resolve $testhostname";
|
||||
warn "Failed to resolve $$addr, using $srcdir/certs/wgethosts\n";
|
||||
exit 77;
|
||||
}
|
||||
|
||||
my $port = 28443;
|
||||
my $cmdline = $WgetTest::WGETPATH . " --secure-protocol=TLSv1".
|
||||
" --ca-certificate=$cdir/certs/test-ca-cert.pem".
|
||||
" --ca-certificate=$srcdir/certs/test-ca-cert.pem".
|
||||
" https://$testhostname:$port/somefile.txt";
|
||||
|
||||
my $expected_error_code = 0;
|
||||
|
@ -3,6 +3,7 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
use Socket;
|
||||
use Cwd;
|
||||
use WgetFeature qw(https);
|
||||
use SSLTest;
|
||||
|
||||
@ -27,22 +28,34 @@ unless ($ossl =~ m/OpenSSL 1/)
|
||||
exit 77;
|
||||
}
|
||||
|
||||
my $srcdir;
|
||||
if (@ARGV) {
|
||||
$srcdir = shift @ARGV;
|
||||
} elsif (defined $ENV{srcdir}) {
|
||||
$srcdir = $ENV{srcdir};
|
||||
}
|
||||
$srcdir = Cwd::abs_path("$srcdir");
|
||||
|
||||
my $cdir = $ENV{'PWD'};
|
||||
# HOSTALIASES env variable allows us to create hosts file alias.
|
||||
my $testhostname = "WgetTestingServer";
|
||||
$ENV{'HOSTALIASES'} = "$cdir/certs/wgethosts";
|
||||
$ENV{'HOSTALIASES'} = "$srcdir/certs/wgethosts";
|
||||
|
||||
my $addr = gethostbyname($testhostname) or
|
||||
my $addr = gethostbyname($testhostname);
|
||||
unless ($addr)
|
||||
{
|
||||
warn "Failed to resolve $addr, using $srcdir/certs/wgethosts\n";
|
||||
exit 77;
|
||||
}
|
||||
unless (inet_ntoa($addr) =~ "127.0.0.1")
|
||||
{
|
||||
warn "Failed to resolve $testhostname";
|
||||
warn "Failed to resolve $$addr, using $srcdir/certs/wgethosts\n";
|
||||
exit 77;
|
||||
}
|
||||
|
||||
my $port = 29443;
|
||||
my $cmdline = $WgetTest::WGETPATH . " --secure-protocol=TLSv1_1".
|
||||
" --ca-certificate=$cdir/certs/test-ca-cert.pem".
|
||||
" --ca-certificate=$srcdir/certs/test-ca-cert.pem".
|
||||
" https://$testhostname:$port/somefile.txt";
|
||||
|
||||
my $expected_error_code = 0;
|
||||
|
@ -27,41 +27,52 @@ unless ($ossl =~ m/OpenSSL 1/)
|
||||
exit 77;
|
||||
}
|
||||
|
||||
my $cdir = $ENV{'PWD'};
|
||||
my $srcdir;
|
||||
if (@ARGV) {
|
||||
$srcdir = shift @ARGV;
|
||||
} elsif (defined $ENV{srcdir}) {
|
||||
$srcdir = $ENV{srcdir};
|
||||
}
|
||||
$srcdir = Cwd::abs_path("$srcdir");
|
||||
|
||||
my $cdir = $ENV{'PWD'};
|
||||
# HOSTALIASES env variable allows us to create hosts file alias.
|
||||
my $testhostname = "WgetTestingServer";
|
||||
$ENV{'HOSTALIASES'} = "$cdir/certs/wgethosts";
|
||||
$ENV{'HOSTALIASES'} = "$srcdir/certs/wgethosts";
|
||||
|
||||
my $addr = gethostbyname($testhostname) or
|
||||
my $addr = gethostbyname($testhostname);
|
||||
unless ($addr)
|
||||
{
|
||||
warn "Failed to resolve $addr, using $srcdir/certs/wgethosts\n";
|
||||
exit 77;
|
||||
}
|
||||
unless (inet_ntoa($addr) =~ "127.0.0.1")
|
||||
{
|
||||
warn "Failed to resolve $testhostname";
|
||||
warn "Failed to resolve $$addr, using $srcdir/certs/wgethosts\n";
|
||||
exit 77;
|
||||
}
|
||||
|
||||
# Create certindex
|
||||
open CERTID, ">", "$cdir/certs/certindex" or
|
||||
warn "Cannot overwrite file $cdir/certs/certindex";
|
||||
open CERTID, ">", "$cdir/certindex" or
|
||||
warn "Cannot overwrite file $cdir/certindex";
|
||||
close CERTID;
|
||||
|
||||
# Create certserial
|
||||
open CERTSN, ">", "$cdir/certs/certserial" or
|
||||
warn "Cannot overwrite file $cdir/certs/certserial";
|
||||
open CERTSN, ">", "$cdir/certserial" or
|
||||
warn "Cannot overwrite file $cdir/certserial";
|
||||
print CERTSN "1122";
|
||||
close CERTSN;
|
||||
|
||||
# Create crlnumber
|
||||
open CRLN, ">", "$cdir/certs/crlnumber" or
|
||||
warn "Cannot overwrite file $cdir/certs/crlnumber";
|
||||
open CRLN, ">", "$cdir/crlnumber" or
|
||||
warn "Cannot overwrite file $cdir/crlnumber";
|
||||
close CRLN;
|
||||
|
||||
# Create Intermediate CA
|
||||
my $caconf = "certs/rootca.conf";
|
||||
my $icrtfile = "certs/interca.crt";
|
||||
my $ikeyfile = "certs/interca.key";
|
||||
my $icsrfile = "certs/interca.csr";
|
||||
my $caconf = "$srcdir/certs/rootca.conf";
|
||||
my $icrtfile = "$cdir/interca.crt";
|
||||
my $ikeyfile = "$cdir/interca.key";
|
||||
my $icsrfile = "$cdir/interca.csr";
|
||||
my $icasubj = "/C=US/ST=CA/L=Intermediate Mystery Spot/O=Int/CN=".
|
||||
"ica-$testhostname/emailAddress=icatester";
|
||||
my $icacmd = "openssl genrsa -out $ikeyfile 4096 && openssl req -new".
|
||||
@ -81,8 +92,8 @@ unless(-e $icrtfile && -e $ikeyfile && $icacheck == 1)
|
||||
}
|
||||
|
||||
# Now create web of trust - Root CA + Intermediate CA
|
||||
open WOT, ">", "$cdir/certs/wotca.pem" or
|
||||
die "Cannot overwrite file $cdir/certs/wotca";
|
||||
open WOT, ">", "$cdir/wotca.pem" or
|
||||
die "Cannot overwrite file $cdir/wotca";
|
||||
open ICA, "<", $icrtfile or die "Cannot read file $icrtfile";
|
||||
while (<ICA>)
|
||||
{
|
||||
@ -90,8 +101,8 @@ while (<ICA>)
|
||||
}
|
||||
print WOT "\n";
|
||||
close ICA;
|
||||
open RCA, "<", "$cdir/certs/test-ca-cert.pem" or
|
||||
die "Cannot read file $cdir/certs/test-ca-cert.pem";
|
||||
open RCA, "<", "$srcdir/certs/test-ca-cert.pem" or
|
||||
die "Cannot read file $srcdir/certs/test-ca-cert.pem";
|
||||
while (<RCA>)
|
||||
{
|
||||
print WOT $_;
|
||||
@ -101,10 +112,10 @@ close RCA;
|
||||
close WOT;
|
||||
|
||||
# Create Test certificate using intermediate CA
|
||||
my $icaconf = "certs/interca.conf";
|
||||
my $usrcrt = "certs/user.crt";
|
||||
my $usrkey = "certs/user.key";
|
||||
my $usrcsr = "certs/user.csr";
|
||||
my $icaconf = "$srcdir/certs/interca.conf";
|
||||
my $usrcrt = "$cdir/user.crt";
|
||||
my $usrkey = "$cdir/user.key";
|
||||
my $usrcsr = "$cdir/user.csr";
|
||||
my $usrsubj = "/C=US/ST=CA/L=User Mystery Spot/O=Int/CN=$testhostname/".
|
||||
"emailAddress=usertester";
|
||||
my $usrcmd = "openssl genrsa -out $usrkey 4096 && ".
|
||||
@ -125,7 +136,7 @@ unless(-e $usrcrt && -e $ikeyfile && $usrcheck == 1)
|
||||
|
||||
# Try Wget using SSL using certificate signed by intermediate CA. Expect error.
|
||||
my $port = 30443;
|
||||
my $cmdline = $WgetTest::WGETPATH . " --ca-certificate=$cdir/certs/".
|
||||
my $cmdline = $WgetTest::WGETPATH . " --ca-certificate=$srcdir/certs/".
|
||||
"test-ca-cert.pem https://$testhostname:$port/somefile.txt";
|
||||
my $expected_error_code = 5;
|
||||
my %existing_files = (
|
||||
@ -152,7 +163,7 @@ if ($sslsock->run() == 0)
|
||||
|
||||
# Retry the test with --no-check-certificate. expect success
|
||||
$port = 31443;
|
||||
$cmdline = $WgetTest::WGETPATH . " --ca-certificate=$cdir/certs/wotca.pem".
|
||||
$cmdline = $WgetTest::WGETPATH . " --ca-certificate=$cdir/wotca.pem".
|
||||
" https://$testhostname:$port/somefile.txt";
|
||||
|
||||
$expected_error_code = 0;
|
||||
|
@ -7,17 +7,17 @@ authorityKeyIdentifier=keyid:always
|
||||
|
||||
[ myca ]
|
||||
dir = ./certs/
|
||||
new_certs_dir = $dir
|
||||
new_certs_dir = ./
|
||||
unique_subject = no
|
||||
certificate = $dir/interca.crt
|
||||
database = $dir/certindex
|
||||
private_key = $dir/interca.key
|
||||
serial = $dir/certserial
|
||||
certificate = interca.crt
|
||||
database = certindex
|
||||
private_key = interca.key
|
||||
serial = certserial
|
||||
default_days = 730
|
||||
default_md = sha1
|
||||
policy = myca_policy
|
||||
x509_extensions = myca_extensions
|
||||
crlnumber = $dir/crlnumber
|
||||
crlnumber = crlnumber
|
||||
default_crl_days = 730
|
||||
|
||||
[ myca_policy ]
|
||||
|
@ -7,17 +7,17 @@ authorityKeyIdentifier=keyid:always
|
||||
|
||||
[ myca ]
|
||||
dir = ./certs/
|
||||
new_certs_dir = $dir
|
||||
new_certs_dir = ./
|
||||
unique_subject = no
|
||||
certificate = $dir/test-ca-cert.pem
|
||||
database = $dir/certindex
|
||||
database = certindex
|
||||
private_key = $dir/test-ca-key.pem
|
||||
serial = $dir/certserial
|
||||
serial = certserial
|
||||
default_days = 730
|
||||
default_md = sha1
|
||||
policy = myca_policy
|
||||
x509_extensions = myca_extensions
|
||||
crlnumber = $dir/crlnumber
|
||||
crlnumber = crlnumber
|
||||
default_crl_days = 730
|
||||
|
||||
[ myca_policy ]
|
||||
|
Loading…
Reference in New Issue
Block a user