prova.pl untested

filter: Statementstmt 0.0% 0 / 54 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod n/a totaltotal 0.0% 0 / 63 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/bin/perl
2  
3 $|=1;
4  
5 use OpenCA::OpenSSL;
6 use OpenCA::X509;
7 use OpenCA::CRL;
8  
9 my $openssl = new OpenCA::OpenSSL( SHELL=>"/usr/bin/openssl" );
10 my @tmpfiles = ("cert.pem","priv.key","req.pem");
11  
12 print "Initializing crypto shell ... \n";
13 $openssl->setParams ( CONFIG=>"/usr/local/OpenCA/stuff/openssl.cnf" );
14  
15 ## $openssl->setParams ( STDERR => "/dev/null" );
16  
17 print "Generating a 512 bit priv Key ...\n";
18 if( not $openssl->genKey( BITS=>512, OUTFILE=>"priv.key" ) ) {
19 print "Error";
20 }
21  
22 print "Generating a Request file ... \n";
23 $openssl->genReq( OUTFILE=>"req.pem", KEYFILE=>"priv.key",
24 DN=>["madwolf\@openca.org", "Massimiliano Pala", "CA", "", "" ] );
25  
26 print "Generating a CA certificate ... \n";
27 $p = $openssl->genCert( KEYFILE=>"priv.key", REQFILE=>"req.pem", DAYS=>150,
28 OUTFILE=>"cert.pem");
29  
30 print "Creating a new X509 object ... \n";
31 my $X509 = new OpenCA::X509( INFILE=>"cert.pem",
32 FORMAT=>"PEM", SHELL=>$openssl);
33  
34 ## print "Creating a new CRL Object ... \n";
35 ## my $CC = new OpenCA::CRL( SHELL=>$openssl, DATA=>$crl );
36 ## if( not $CC ) {
37 ## print "Error!\n";
38 ## }
39 ## print " * CRL Version: " . $CC->getParsed()->{VERSION} . "\n";
40 ## print " * Last Update: " . $CC->getParsed()->{LAST_UPDATE} . "\n";
41 ## print " * Next Update: " . $CC->getParsed()->{NEXT_UPDATE} . "\n";
42 ## print " * S-Algorithm: " . $CC->getParsed()->{ALGORITHM} . "\n";
43  
44 print "Creating a new CRL Object (2) ... \n";
45 my $CC = new OpenCA::CRL( SHELL=>$openssl, CACERT=>"cert.pem",
46 CAKEY=>"priv.key", DAYS=>"31" );
47 if( not $CC ) {
48 print "Error!\n";
49 exit;
50 }
51  
52 ## print $CC->txtCRL;
53  
54 print " * CRL Version: " . $CC->getParsed()->{VERSION} . "\n";
55 print " * Last Update: " . $CC->getParsed()->{LAST_UPDATE} . "\n";
56 print " * Next Update: " . $CC->getParsed()->{NEXT_UPDATE} . "\n";
57 print " * S-Algorithm: " . $CC->getParsed()->{ALGORITHM} . "\n";
58  
59 foreach $cert ( @{ $CC->getParsed()->{LIST}} ) {
60 print " - Revoked Certificate : " . $cert->{SERIAL};
61 print " (on " . $cert->{DATE} . ")\n";
62 };
63  
64  
65 print "Sleeping 2 secs ... \n";
66 sleep 2;
67  
68 print "Creating a new CRL Object (3) ... \n";
69 my $RR = new OpenCA::CRL( SHELL=>$openssl, CACERT=>"cert.pem",
70 CAKEY=>"priv.key", DAYS=>"31" );
71 if( not $RR ) {
72 print "Error! $? -> $!\n";
73 }
74  
75 ## print $RR->txtCRL;
76  
77 print " * CRL Version: " . $RR->getParsed()->{VERSION} . "\n";
78 print " * Last Update: " . $RR->getParsed()->{LAST_UPDATE} . "\n";
79 print " * Next Update: " . $RR->getParsed()->{NEXT_UPDATE} . "\n";
80 print " * S-Algorithm: " . $RR->getParsed()->{ALGORITHM} . "\n";
81  
82 ## if( not $PP ) {
83 ## print "Error!\n";
84 ##}
85  
86 foreach $cert ( @{ $CC->getParsed()->{LIST}} ) {
87 print " - Revoked Certificate : " . $cert->{SERIAL};
88 print " (on " . $cert->{DATE} . ")\n";
89 };
90  
91 foreach $tmp (@tmpfiles) {
92 unlink( "$tmp" );
93 }
94  
95 exit 0;
96