prova.pl untested

filter: Statementstmt 0.0% 0 / 40 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 46 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::REQ;
8 use OpenCA::Tools;
9  
10 my $openssl = new OpenCA::OpenSSL( SHELL=>"/usr/bin/openssl" );
11 my $tools = new OpenCA::Tools();
12  
13 my @tmpfiles = ("priv.key","req.pem");
14  
15 print "Initializing crypto shell ... \n";
16 $openssl->setParams ( CONFIG=>"/usr/ssl/openssl.cnf" );
17 $openssl->setParams ( STDERR => "/dev/null" );
18  
19 print "Generating a 768 bit priv Key ...\n";
20 if( not $openssl->genKey( BITS=>768, OUTFILE=>"priv.key" ) ) {
21 print "Error";
22 }
23  
24 print "Generating a Request file ... \n";
25 $openssl->genReq( OUTFILE=>"req.pem", KEYFILE=>"priv.key",
26 SUBJECT=>"Email=madwolf\@openca.org, CN=Massimiliano Pala, c=IT" );
27  
28 my $old = new OpenCA::REQ(SHELL=>$openssl,
29 KEYFILE=>"priv.key",
30 FORMAT=>"PEM",
31 SUBJECT=>"Email=you\@openca.org, CN=John Doe, OU=Department, O=OpenCA, C=IT" );
32  
33 # print $old->getParsed()->{DN} . "\n";
34  
35 ## print $openssl->genReq( KEYFILE=>"priv.key", OUTFORM=>TXT,
36 ## DN=>["madwolf\@openca.org", "Massimiliano Pala", "CA", "", "" ] );
37  
38 # print "Parsing a REVOKE request file ... \n";
39 # my $REQ = new OpenCA::REQ(SHELL=>$openssl, DATA=>$tools->getFile("revoke.req"));
40 # print "CERT DN => " . $REQ->getParsed()->{REVOKE_CERTIFICATE_DN} . "\n";
41 # print "\n\n";
42  
43 print "Parsing an SPKAC request file ... \n";
44 my $REQ = new OpenCA::REQ(SHELL=>$openssl, INFILE=>"spkac.req", FORMAT=>SPKAC);
45 ## print "Parsing a RENEW request file ... \n";
46 ## my $REQ = new OpenCA::REQ(SHELL=>$openssl, INFILE=>"renew.req", FORMAT=>RENEW);
47 # my $REQ = new OpenCA::REQ(SHELL=>$openssl, INFILE=>"req.pem", FORMAT=>PEM);
48 # print "Error! $!\n" && exit 1 if ( not $REQ );
49 ## print "DN => \n " . $REQ->getParsed()->{DN} . "\n";
50  
51 ## $REQ = $old;
52 ## print $REQ->getTXT();
53  
54 print " OPERATOR => " . $REQ->getParsed()->{OPERATOR} . "\n";
55 print " NOTBEFORE => " . $REQ->getParsed()->{NOTBEFORE} . "\n";
56 print " APPROVED => " . $REQ->getParsed()->{APPROVED} . "\n";
57 print " DN => " . $REQ->getParsed()->{DN} . "\n";
58 print " CN => " . $REQ->getParsed()->{CN} . "\n";
59 print " OUs => @{$REQ->getParsed()->{OU}}\n";
60 print " KEY SIZE => " . $REQ->getParsed()->{KEYSIZE} . "\n";
61 print " SPKAC => " . $REQ->getParsed()->{SPKAC} . "\n";
62 print " PUBKEY => " . $REQ->getParsed()->{PUBKEY} . "\n";
63 print "KEY DIGEST => " . $REQ->getParsed()->{KEY_DIGEST} . "\n";
64  
65 foreach $tmp (@tmpfiles) {
66 unlink( "$tmp" );
67 }
68  
69 exit 0;
70