3 # $Id: httpsserver.pl,v 1.1.1.1 2008-09-23 16:32:06 hoffman Exp $
4 # This is the HTTPS and FTPS server designed for the curl test suite.
6 # It is actually just a layer that runs stunnel properly.
11 my $stunnel = "stunnel";
20 my $verbose=0; # set to 1 for debugging
22 my $port = 8991; # just our default, weird enough
23 my $target_port = 8999; # default test http-server port
32 if($ARGV[0] eq "-v") {
35 if($ARGV[0] eq "-w") {
36 return 0; # return success, means we have stunnel working!
38 elsif($ARGV[0] eq "-p") {
42 elsif($ARGV[0] eq "-r") {
43 $target_port=$ARGV[1];
46 elsif($ARGV[0] eq "-s") {
50 elsif($ARGV[0] eq "-d") {
54 elsif($ARGV[0] =~ /^(\d+)$/) {
59 my $conffile="$path/stunnel.conf"; # stunnel configuration data
60 my $certfile="$srcdir/stunnel.pem"; # stunnel server certificate
61 my $pidfile="$path/.$proto.pid"; # stunnel process pid file
63 open(CONF
, ">$conffile") || exit 1;
74 connect = $target_port
77 #system("chmod go-rwx $conffile $certfile"); # secure permissions
79 # works only with stunnel versions < 4.00
80 my $cmd="$stunnel -p $certfile -P $pidfile -d $port -r $target_port 2>/dev/null";
82 # use some heuristics to determine stunnel version
83 my $version_ge_4=system("$stunnel -V 2>&1|grep '^stunnel.* on '>/dev/null 2>&1");
84 # works only with stunnel versions >= 4.00
85 if ($version_ge_4) { $cmd="$stunnel $conffile"; }
88 print uc($proto)." server: $cmd\n";
91 my $rc = system($cmd);
95 print STDERR
"stunnel exited with $rc!\n";