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: initial enrollment");
26 my $cgi_dir = $config{cgi_dir};
30 if (system("$sscep >/dev/null $stderr") != 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 ok(copy("bin/scep", $cgi_dir));
50 chmod 0755, $cgi_dir . '/scep';
52 my $scep_uri = "http://127.0.0.1:$config{http_server_port}/cgi-bin/scep";
54 my $cacert_base = "$config{server_dir}/cacert";
64 # recoverable fork error
65 if ($redo_count > 5) {
66 print STDERR "FAILED.\n";
67 print STDERR "Could not fork process\n";
77 print STDERR "FAILED.\n";
78 print STDERR "Could not fork process: $ERRNO\n";
85 # child process pid is available in $pid
88 # create a key and a certificate request
89 my $openssl = $config{'openssl'};
90 `$openssl genrsa -out t/instance/request_key.pem 1024 $stderr`;
91 `(echo '.'; echo '.'; echo '.'; echo 'OpenXPKI'; echo 'SCEP test certificate'; echo 'SCEP test certificate'; echo '.'; echo '.'; echo '.')| openssl req -new -key t/instance/request_key.pem -out t/instance/request.csr $stderr`;
93 # use sscep to start the enrollment
94 my $scep_uri = "http://127.0.0.1:$config{http_server_port}/cgi-bin/scep";
95 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 5 -n 0 -v $stderr`;
97 print STDERR $scep_result;
99 ok($scep_result =~ m{pkistatus:\ PENDING}xms);
105 $kid = waitpid(-1, WNOHANG);
111 # parent process pid is available with getppid
113 # start a minimal HTTP server to test the CGI
114 my $http_server = getcwd . "/t/http_server.pl";
116 exec("perl $http_server $config{http_server_port}");