--- /dev/null
+extensions = x509v3
+
+[ x509v3 ]
+subjectAltName = DNS:localhost
+keyUsage = keyEncipherment,digitalSignature,keyAgreement
+extendedKeyUsage = serverAuth,clientAuth
+subjectKeyIdentifier = hash
+authorityKeyIdentifier = keyid
+basicConstraints = CA:false
+authorityInfoAccess = @issuer_info
+crlDistributionPoints = @crl_info
+
+[ crl_ext ]
+authorityKeyIdentifier = keyid:always
+authorityInfoAccess = @issuer_info
+
+[ issuer_info ]
+caIssuers;URI.0 = http://test.curl.se/ca/EdelCurlRoot.cer
+
+[ crl_info ]
+URI.0 = http://test.curl.se/ca/EdelCurlRoot.crl
+
+[ req ]
+default_bits = 2048
+distinguished_name = req_DN
+default_md = sha256
+string_mask = utf8only
+
+[ req_DN ]
+countryName = "Country Name is Northern Nowhere"
+countryName_value = NN
+organizationName = "Organization Name"
+organizationName_value = Edel Curl Arctic Illudium Research Cloud
+commonName = "Common Name"
+commonName_value = localhost
my $idnum = 1; # default stunneled server instance number
my $proto = 'https'; # default secure server protocol
my $conffile; # stunnel configuration file
+my $cafile; # certificate CA PEM file
my $certfile; # certificate chain PEM file
+my $mtls = 0; # Whether to verify client certificates
#***************************************************************************
# stunnel requires full path specification for several files.
shift @ARGV;
}
}
+ elsif($ARGV[0] eq '--mtls') {
+ $mtls = 1;
+ }
else {
print STDERR "\nWarning: secureserver.pl unknown parameter: $ARGV[0]\n";
}
$conffile = "$piddir/${proto}_stunnel.conf";
+$cafile = abs_path("$path/certs/test-ca.cacert");
$certfile = $stuncert ? "certs/$stuncert" : "certs/test-localhost.pem";
$certfile = abs_path($certfile);
$tstunnel_windows = 1;
# convert Cygwin/MinGW paths to Windows format
+ $cafile = pathhelp::sys_native_abs_path($cafile);
$certfile = pathhelp::sys_native_abs_path($certfile);
}
print $stunconf "cert = $certfile\n";
print $stunconf "debug = $loglevel\n";
print $stunconf "socket = $socketopt\n";
+ if($mtls) {
+ print $stunconf "CAfile = $cafile\n";
+ print $stunconf "verifyChain = yes\n";
+ }
if($fips_support) {
# disable fips in case OpenSSL doesn't support it
print $stunconf "fips = no\n";
}
}
for my $proto (('tftp', 'sftp', 'socks', 'ssh', 'rtsp', 'httptls',
- 'dict', 'smb', 'smbs', 'telnet', 'mqtt')) {
+ 'dict', 'smb', 'smbs', 'telnet', 'mqtt', 'https-mtls')) {
for my $ipvnum ((4, 6)) {
for my $idnum ((1, 2)) {
my $serv = servername_id($proto, $ipvnum, $idnum);
$flags .= "--ipv$ipvnum --proto $proto ";
$flags .= "--certfile \"$certfile\" " if($certfile ne 'certs/test-localhost.pem');
$flags .= "--stunnel \"$stunnel\" --srcdir \"$srcdir\" ";
+ if($proto eq "https-mtls") {
+ $flags .= "--mtls ";
+ }
if($proto eq "gophers") {
$flags .= "--connect " . protoport("gopher");
}
elsif($what eq "file") {
# we support it but have no server!
}
- elsif($what eq "https") {
+ elsif($what eq "https" || $what eq "https-mtls") {
if(!$stunnel) {
# we can't run https tests without stunnel
return ("no stunnel", 4);
}
- if($runcert{'https'} && ($runcert{'https'} ne $certfile)) {
+ if($runcert{$what} && ($runcert{$what} ne $certfile)) {
# stop server when running and using a different cert
- if(stopserver('https')) {
+ if(stopserver($what)) {
return ("failed stopping HTTPS server with different cert", 3);
}
# also stop http server, we do not know which state it is in
return ("failed stopping HTTP server", 3);
}
}
- if($run{'https'} &&
- !responsive_http_server("https", $verbose, 0,
- protoport('https'))) {
- if(stopserver('https')) {
+ if($run{$what} &&
+ !responsive_http_server($what, $verbose, 0,
+ protoport($what))) {
+ if(stopserver($what)) {
return ("failed stopping unresponsive HTTPS server", 3);
}
# also stop http server, we do not know which state it is in
}
}
# check a running http server if we not already checked https
- if($run{'http'} && !$run{'https'} &&
+ if($run{'http'} && !$run{$what} &&
!responsive_http_server("http", $verbose, 0,
protoport('http'))) {
if(stopserver('http')) {
logmsg sprintf("* pid http => %d %d\n", $pid, $pid2) if($verbose);
$run{'http'}="$pid $pid2";
}
- if(!$run{'https'}) {
- ($serr, $pid, $pid2, $PORT{'https'}) =
- runhttpsserver($verbose, "https", "", $certfile);
+ if(!$run{$what}) {
+ ($serr, $pid, $pid2, $PORT{$what}) =
+ runhttpsserver($verbose, $what, "", $certfile);
if($pid <= 0) {
return ("failed starting HTTPS server (stunnel)", $serr);
}
- logmsg sprintf("* pid https => %d %d\n", $pid, $pid2)
+ logmsg sprintf("* pid $what => %d %d\n", $pid, $pid2)
if($verbose);
- $run{'https'}="$pid $pid2";
+ $run{$what}="$pid $pid2";
}
}
elsif($what eq "http/2") {
foreach my $proto ('DICT',
'FTP', 'FTP6', 'FTPS',
'GOPHER', 'GOPHER6', 'GOPHERS',
- 'HTTP', 'HTTP6', 'HTTPS',
+ 'HTTP', 'HTTP6', 'HTTPS', 'HTTPS-MTLS',
'HTTPSPROXY', 'HTTPTLS', 'HTTPTLS6',
'HTTP2', 'HTTP2TLS',
'HTTP3',