1 use Test::More tests => 2;
8 use POSIX ":sys_wait_h";
15 require 't/common.pl';
17 my $debug = $config{debug};
18 my $stderr = '2>/dev/null';
23 diag("SCEP Client Test: download initial certificate");
26 my $cgi_dir = $config{cgi_dir};
30 if (system("$sscep >/dev/null 2>&1") != 0) {
31 skip "sscep binary not installed.", 2;
33 if (! (`$config{openssl} version` =~ m{\A OpenSSL\ 0\.9\.8 }xms)) {
34 skip "OpenSSL 0.9.8 not available.", 2;
37 #ok(mkpath([ $cgi_dir ]));
38 # create configuration
39 open my $HANDLE, ">", "$cgi_dir/scep.cfg";
40 print $HANDLE "[global]\n";
41 print $HANDLE "socket=$config{socket_file}\n";
42 print $HANDLE "realm=I18N_OPENXPKI_DEPLOYMENT_TEST_DUMMY_CA\n";
43 print $HANDLE "iprange=127.0.0.0/8\n";
44 print $HANDLE "profile=I18N_OPENXPKI_PROFILE_TLS_SERVER\n";
45 print $HANDLE "servername=testscepserver1\n";
46 print $HANDLE "encryption_algorithm=3DES\n";
49 my $scep_uri = "http://127.0.0.1:$config{http_server_port}/cgi-bin/scep";
51 my $cacert_base = "$config{server_dir}/cacert";
61 # recoverable fork error
62 if ($redo_count > 5) {
63 print STDERR "FAILED.\n";
64 print STDERR "Could not fork process\n";
74 print STDERR "FAILED.\n";
75 print STDERR "Could not fork process: $ERRNO\n";
82 # child process pid is available in $pid
85 # use sscep to download certificate
86 my $scep_uri = "http://127.0.0.1:$config{http_server_port}/cgi-bin/scep";
87 my $scep_result = `$sscep enroll -u $scep_uri -c $config{server_dir}/cacert-0 -k t/instance/request_key.pem -r t/instance/request.csr -l t/instance/certificate -t 10 -n 5 -v $stderr`;
89 print STDERR $scep_result;
91 ok($scep_result =~ m{pkistatus:\ SUCCESS}xms);
92 ok(-s 't/instance/certificate');
98 $kid = waitpid(-1, WNOHANG);
104 # parent process pid is available with getppid
106 # start a minimal HTTP server to test the CGI
107 my $http_server = getcwd . "/t/http_server.pl";
109 exec("perl $http_server $config{http_server_port}");