| 1 | ## OpenCA::CRL | ||||||||||||||||||||||||||||
| 2 | ## | ||||||||||||||||||||||||||||
| 3 | ## Copyright (C) 1998-1999 Massimiliano Pala (madwolf@openca.org) | ||||||||||||||||||||||||||||
| 4 | ## All rights reserved. | ||||||||||||||||||||||||||||
| 5 | ## | ||||||||||||||||||||||||||||
| 6 | ## This library is free for commercial and non-commercial use as long as | ||||||||||||||||||||||||||||
| 7 | ## the following conditions are aheared to. The following conditions | ||||||||||||||||||||||||||||
| 8 | ## apply to all code found in this distribution, be it the RC4, RSA, | ||||||||||||||||||||||||||||
| 9 | ## lhash, DES, etc., code; not just the SSL code. The documentation | ||||||||||||||||||||||||||||
| 10 | ## included with this distribution is covered by the same copyright terms | ||||||||||||||||||||||||||||
| 11 | ## | ||||||||||||||||||||||||||||
| 12 | ## Copyright remains Massimiliano Pala's, and as such any Copyright notices | ||||||||||||||||||||||||||||
| 13 | ## in the code are not to be removed. | ||||||||||||||||||||||||||||
| 14 | ## If this package is used in a product, Massimiliano Pala should be given | ||||||||||||||||||||||||||||
| 15 | ## attribution as the author of the parts of the library used. | ||||||||||||||||||||||||||||
| 16 | ## This can be in the form of a textual message at program startup or | ||||||||||||||||||||||||||||
| 17 | ## in documentation (online or textual) provided with the package. | ||||||||||||||||||||||||||||
| 18 | ## | ||||||||||||||||||||||||||||
| 19 | ## Redistribution and use in source and binary forms, with or without | ||||||||||||||||||||||||||||
| 20 | ## modification, are permitted provided that the following conditions | ||||||||||||||||||||||||||||
| 21 | ## are met: | ||||||||||||||||||||||||||||
| 22 | ## 1. Redistributions of source code must retain the copyright | ||||||||||||||||||||||||||||
| 23 | ## notice, this list of conditions and the following disclaimer. | ||||||||||||||||||||||||||||
| 24 | ## 2. Redistributions in binary form must reproduce the above copyright | ||||||||||||||||||||||||||||
| 25 | ## notice, this list of conditions and the following disclaimer in the | ||||||||||||||||||||||||||||
| 26 | ## documentation and/or other materials provided with the distribution. | ||||||||||||||||||||||||||||
| 27 | ## 3. All advertising materials mentioning features or use of this software | ||||||||||||||||||||||||||||
| 28 | ## must display the following acknowledgement: | ||||||||||||||||||||||||||||
| 29 | ## "This product includes OpenCA software written by Massimiliano Pala | ||||||||||||||||||||||||||||
| 30 | ## (madwolf@openca.org) and the OpenCA Group (www.openca.org)" | ||||||||||||||||||||||||||||
| 31 | ## 4. If you include any Windows specific code (or a derivative thereof) from | ||||||||||||||||||||||||||||
| 32 | ## some directory (application code) you must include an acknowledgement: | ||||||||||||||||||||||||||||
| 33 | ## "This product includes OpenCA software (www.openca.org)" | ||||||||||||||||||||||||||||
| 34 | ## | ||||||||||||||||||||||||||||
| 35 | ## THIS SOFTWARE IS PROVIDED BY OPENCA DEVELOPERS ``AS IS'' AND | ||||||||||||||||||||||||||||
| 36 | ## ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||||||||||||||||||||||||||
| 37 | ## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||||||||||||||||||||||||||
| 38 | ## ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||||||||||||||||||||||||||||
| 39 | ## FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||||||||||||||||||||||||||
| 40 | ## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||||||||||||||||||||||||||
| 41 | ## OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||||||||||||||||||||||||||
| 42 | ## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||||||||||||||||||||||||||
| 43 | ## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||||||||||||||||||||||||||
| 44 | ## OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||||||||||||||||||||||||||
| 45 | ## SUCH DAMAGE. | ||||||||||||||||||||||||||||
| 46 | ## | ||||||||||||||||||||||||||||
| 47 | ## The licence and distribution terms for any publically available version or | ||||||||||||||||||||||||||||
| 48 | ## derivative of this code cannot be changed. i.e. this code cannot simply be | ||||||||||||||||||||||||||||
| 49 | ## copied and put under another distribution licence | ||||||||||||||||||||||||||||
| 50 | ## [including the GNU Public Licence.] | ||||||||||||||||||||||||||||
| 51 | ## | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | ## the module's errorcode is 76 | ||||||||||||||||||||||||||||
| 54 | ## | ||||||||||||||||||||||||||||
| 55 | ## functions: | ||||||||||||||||||||||||||||
| 56 | ## | ||||||||||||||||||||||||||||
| 57 | ## new 11 | ||||||||||||||||||||||||||||
| 58 | ## init 12 | ||||||||||||||||||||||||||||
| 59 | ## parseCRL 13 | ||||||||||||||||||||||||||||
| 60 | ## getHeader 21 | ||||||||||||||||||||||||||||
| 61 | ## getBody 22 | ||||||||||||||||||||||||||||
| 62 | ## getTXT 31 | ||||||||||||||||||||||||||||
| 63 | ## getParsed 41 | ||||||||||||||||||||||||||||
| 64 | ## getPEM 32 | ||||||||||||||||||||||||||||
| 65 | ## getDER 33 | ||||||||||||||||||||||||||||
| 66 | ## getItem 51 | ||||||||||||||||||||||||||||
| 67 | ## getSerial 52 | ||||||||||||||||||||||||||||
| 68 | ## setParams 61 | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | package OpenCA::CRL; | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 1 | our ($errno, $errval); | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 1 | ▶ | ($OpenCA::CRL::VERSION = '$Revision: 1.17 $' )=~ s/(?:^.*: (\d+))|(?:\s+\$$)/defined $1?"0\.9":""/eg; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 1 | my %params = ( | |||||||||||||||||||||||||||
| 79 | crl => undef, | ||||||||||||||||||||||||||||
| 80 | item => undef, | ||||||||||||||||||||||||||||
| 81 | pwd => undef, | ||||||||||||||||||||||||||||
| 82 | crlFormat => undef, | ||||||||||||||||||||||||||||
| 83 | pemCRL => undef, | ||||||||||||||||||||||||||||
| 84 | derCRL => undef, | ||||||||||||||||||||||||||||
| 85 | txtCRL => undef, | ||||||||||||||||||||||||||||
| 86 | parsedItem => undef, | ||||||||||||||||||||||||||||
| 87 | backend => undef, | ||||||||||||||||||||||||||||
| 88 | beginHeader => undef, | ||||||||||||||||||||||||||||
| 89 | endHeader => undef | ||||||||||||||||||||||||||||
| 90 | ); | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub setError { | ||||||||||||||||||||||||||
|
Subroutine
setError: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 93 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 0 | ▶ | if (scalar (@_) == 4) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | 0 | my $keys = { @_ }; | |||||||||||||||||||||||||||
| 97 | 0 | $errval = $keys->{ERRVAL}; | |||||||||||||||||||||||||||
| 98 | 0 | $errno = $keys->{ERRNO}; | |||||||||||||||||||||||||||
| 99 | } else { | ||||||||||||||||||||||||||||
| 100 | 0 | $errno = $_[0]; | |||||||||||||||||||||||||||
| 101 | 0 | $errval = $_[1]; | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | ## support for: return $self->setError (1234, "Something fails.") if (not $xyz); | ||||||||||||||||||||||||||||
| 105 | 0 | return undef; | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 109 | 0 | my $that = shift; | |||||||||||||||||||||||||||
| 110 | 0 | ▶ | my $class = ref($that) || $that; | ||||||||||||||||||||||||||
|
Condition0%0/3
ref $that || $that
MC/DC0%0/2
ref $that || $that
ref $that
$that
Truth table0%0/3
A || B
A= ref $thatB= $that
| |||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 0 | my $self = { | |||||||||||||||||||||||||||
| 113 | %params, | ||||||||||||||||||||||||||||
| 114 | }; | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 0 | bless $self, $class; | |||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 0 | my $keys = { @_ }; | |||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 0 | $self->{crl} = $keys->{DATA}; | |||||||||||||||||||||||||||
| 121 | 0 | $self->{pwd} = $keys->{PASSWD}; | |||||||||||||||||||||||||||
| 122 | 0 | ▶ | $self->{crlFormat} = ( $keys->{FORMAT} or $keys->{INFORM} or "PEM"); | ||||||||||||||||||||||||||
|
Condition0%0/5
$keys->{'FORMAT'} || $keys->{'INFORM'} || 'PEM'
$keys->{"FORMAT"} or $keys->{"INFORM"}
MC/DC0%0/2
$keys->{'FORMAT'} || $keys->{'INFORM'} || 'PEM'
$keys->{"FORMAT"}
$keys->{"INFORM"}
Truth table0%0/3
A or B
A= $keys->{"FORMAT"}B= $keys->{"INFORM"}
| |||||||||||||||||||||||||||||
| 123 | 0 | $self->{backend} = $keys->{SHELL}; | |||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | return $self->setError (7611011, "OpenCA::CRL->new: There is no crypto-backend specified.") | ||||||||||||||||||||||||||||
| 126 | 0 | ▶ | if( not $self->{backend} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 0 | my $infile = $keys->{INFILE}; | |||||||||||||||||||||||||||
| 129 | 0 | my $cakey = $keys->{CAKEY}; | |||||||||||||||||||||||||||
| 130 | 0 | my $cacert = $keys->{CACERT}; | |||||||||||||||||||||||||||
| 131 | 0 | my $days = $keys->{DAYS}; | |||||||||||||||||||||||||||
| 132 | 0 | my $exts = $keys->{EXTS}; | |||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 0 | $self->{beginHeader} = "-----BEGIN HEADER-----"; | |||||||||||||||||||||||||||
| 135 | 0 | $self->{endHeader} = "-----END HEADER-----"; | |||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 0 | ▶ | if (defined($infile) and ($infile ne "") ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $infile and $infile ne ""
MC/DC0%0/2
defined $infile and $infile ne ""
defined $infile
$infile ne ""
Truth table0%0/3
A and B
A= defined $infileB= $infile ne ""
| |||||||||||||||||||||||||||||
| 138 | 0 | my $tmpLine; | |||||||||||||||||||||||||||
| 139 | 0 | ▶ | open( FD, "<$infile" ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 140 | or return $self->setError (7611021, "OpenCA::CRL->new: Cannot open infile $infile for reading."); | ||||||||||||||||||||||||||||
| 141 | 0 | ▶ | while( $tmpLine = <FD> ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | 0 | $self->{crl} .= $tmpLine; | |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | 0 | close(FD); | |||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 0 | ▶ | if (not $self->{crl}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | { | ||||||||||||||||||||||||||||
| 149 | # the can be stored directly in the token ({backend}) | ||||||||||||||||||||||||||||
| 150 | # | ||||||||||||||||||||||||||||
| 151 | #if( ($cacert) or ($cakey) ) { | ||||||||||||||||||||||||||||
| 152 | # return $self->setError (7611031, "OpenCA::CRL->new: You must specify the CA-certificate too ". | ||||||||||||||||||||||||||||
| 153 | # "if you want to issue a CRL.") | ||||||||||||||||||||||||||||
| 154 | # if (not $cacert); | ||||||||||||||||||||||||||||
| 155 | # return $self->setError (7611032, "OpenCA::CRL->new: You must specify the CA's private key too ". | ||||||||||||||||||||||||||||
| 156 | # "if you want to issue a CRL.") | ||||||||||||||||||||||||||||
| 157 | # if (not $cakey); | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | $self->{crl} = $self->{backend}->issueCrl( | ||||||||||||||||||||||||||||
| 160 | CAKEY => $cakey, | ||||||||||||||||||||||||||||
| 161 | USE_ENGINE => 1, | ||||||||||||||||||||||||||||
| 162 | CACERT => $cacert, | ||||||||||||||||||||||||||||
| 163 | OUTFORM => $self->{crlFormat}, | ||||||||||||||||||||||||||||
| 164 | DAYS => $days, | ||||||||||||||||||||||||||||
| 165 | PASSWD => $self->{pwd}, | ||||||||||||||||||||||||||||
| 166 | EXTS => $exts, | ||||||||||||||||||||||||||||
| 167 | 0 | NOUNIQUEDN => $keys->{NOUNIQUEDN} ); | |||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | return $self->setError (7611035, "OpenCA::CRL->new: Failed to issue a new CRL ". | ||||||||||||||||||||||||||||
| 170 | "(".$OpenCA::OpenSSL::errno.")\n".$OpenCA::OpenSSL::errval) | ||||||||||||||||||||||||||||
| 171 | 0 | ▶ | if ( not $self->{crl} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 0 | ▶ | if ( $self->{crl} ne "" ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 176 | 0 | $self->{item} = $self->{crl}; | |||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 0 | $self->{crl} = $self->getBody( ITEM=>$self->{item} ); | |||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 0 | ▶ | if ( not $self->init()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 181 | 0 | return $self->setError (7611041, "OpenCA::CRL->new: Failed to issue a new CRL ". | |||||||||||||||||||||||||||
| 182 | "($errno)\n$errval"); | ||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 0 | return $self; | |||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | 0 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 192 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 193 | 0 | my $keys = { @_ }; | |||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | return $self->setError (7612011, "OpenCA::CRL->init: There is no CRL present.") | ||||||||||||||||||||||||||||
| 196 | 0 | ▶ | if (not $self->{crl}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | 0 | $self->{pemCRL} = ""; | |||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 0 | $self->{derCRL} = ""; | |||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 0 | $self->{txtCRL} = ""; | |||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 0 | $self->{parsedItem} = $self->parseCRL(); | |||||||||||||||||||||||||||
| 205 | return $self->setError (7612021, "OpenCA::CRL->init: Cannot parse CRL ($errno)\n$errval") | ||||||||||||||||||||||||||||
| 206 | 0 | ▶ | if (not $self->{parsedItem}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 0 | return 1; | |||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 0 | ▶ | sub parseCRL { | ||||||||||||||||||||||||||
|
Subroutine
parseCRL: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 214 | 0 | my $keys = { @_ }; | |||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | 0 | my ( $version, $issuer, $last, $next, $alg, $tmp); | |||||||||||||||||||||||||||
| 217 | 0 | my @list; | |||||||||||||||||||||||||||
| 218 | 0 | my @certs; | |||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 0 | my ( $head, $body ); | |||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 0 | my @attList = ( "VERSION", "ISSUER", "NEXTUPDATE", "LASTUPDATE", "SIGNATURE_ALGORITHM", "REVOKED" ); | |||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | my $hret = $self->{backend}->getCRLAttribute( | ||||||||||||||||||||||||||||
| 225 | ATTRIBUTE_LIST => \@attList, | ||||||||||||||||||||||||||||
| 226 | DATA => $self->{crl}, | ||||||||||||||||||||||||||||
| 227 | 0 | INFORM => $self->{crlFormat}); | |||||||||||||||||||||||||||
| 228 | 0 | ▶ | if (not $hret) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 229 | 0 | return $self->setError (7613015, "OpenCA::CRL->parseCRL: Cryptobackend fails ". | |||||||||||||||||||||||||||
| 230 | "(".$OpenCA::OpenSSL::errno.")\n".$OpenCA::OpenSSL::errval); | ||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | ## Parse lines ... | ||||||||||||||||||||||||||||
| 234 | 0 | @certs = split ( /\n/i, $hret->{REVOKED} ); | |||||||||||||||||||||||||||
| 235 | 0 | ▶ | for (my $i=0; $i<scalar @certs; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 236 | { | ||||||||||||||||||||||||||||
| 237 | 0 | my $serial = $certs[$i++]; | |||||||||||||||||||||||||||
| 238 | 0 | my $date = $certs[$i]; | |||||||||||||||||||||||||||
| 239 | 0 | my $ext = ""; | |||||||||||||||||||||||||||
| 240 | 0 | ▶ | while ($certs[$i+1] =~ /^ /) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 241 | 0 | $ext .= $certs[++$i]."\n"; | |||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | 0 | my $entry = { | |||||||||||||||||||||||||||
| 245 | SERIAL => $serial, | ||||||||||||||||||||||||||||
| 246 | DATE => $date }; | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 0 | @list = ( @list, $entry ); | |||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | my $ret = { | ||||||||||||||||||||||||||||
| 252 | VERSION => $hret->{VERSION}, | ||||||||||||||||||||||||||||
| 253 | ALGORITHM => $hret->{SIGNATURE_ALGORITHM}, | ||||||||||||||||||||||||||||
| 254 | ISSUER => $hret->{ISSUER}, | ||||||||||||||||||||||||||||
| 255 | LAST_UPDATE => $hret->{LASTUPDATE}, | ||||||||||||||||||||||||||||
| 256 | NEXT_UPDATE => $hret->{NEXTUPDATE}, | ||||||||||||||||||||||||||||
| 257 | BODY => $self->getBody( ITEM=> $self->{item} ), | ||||||||||||||||||||||||||||
| 258 | ITEM => $self->getBody( ITEM=> $self->{item} ), | ||||||||||||||||||||||||||||
| 259 | 0 | HEADER => $self->getHeader ( ITEM=>$self->{item} ), | |||||||||||||||||||||||||||
| 260 | LIST => [ @list ], | ||||||||||||||||||||||||||||
| 261 | FLAG_EXPORT_STATE => 0 | ||||||||||||||||||||||||||||
| 262 | }; | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | 0 | return $ret; | |||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | 0 | ▶ | sub getHeader { | ||||||||||||||||||||||||||
|
Subroutine
getHeader: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 268 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 269 | 0 | my $keys = { @_ }; | |||||||||||||||||||||||||||
| 270 | 0 | my $req = $keys->{ITEM}; | |||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | 0 | my ( $txt, $ret, $i, $key, $val ); | |||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | 0 | my $beginHeader = $self->{beginHeader}; | |||||||||||||||||||||||||||
| 275 | 0 | my $endHeader = $self->{endHeader}; | |||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | 0 | ▶ | if( ($txt) = ( $req =~ /$beginHeader\n([\S\s\n]+)\n$endHeader/m) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 278 | 0 | foreach $i ( split ( /\n/, $txt ) ) { | |||||||||||||||||||||||||||
| 279 | 0 | $i =~ s/\s*=\s*/=/; | |||||||||||||||||||||||||||
| 280 | 0 | ( $key, $val ) = ( $i =~ /(.*)\s*=\s*(.*)\s*/ ); | |||||||||||||||||||||||||||
| 281 | 0 | $ret->{$key} = $val; | |||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | 0 | return $ret; | |||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | 0 | ▶ | sub getBody { | ||||||||||||||||||||||||||
|
Subroutine
getBody: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 289 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 290 | 0 | my $keys = { @_ }; | |||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | 0 | my $ret = $keys->{ITEM}; | |||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 0 | my $beginHeader = $self->{beginHeader}; | |||||||||||||||||||||||||||
| 295 | 0 | my $endHeader = $self->{endHeader}; | |||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | ## Let's throw away text between the two headers, included | ||||||||||||||||||||||||||||
| 298 | 0 | $ret =~ s/($beginHeader[\S\s\n]+$endHeader\n)//; | |||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | 0 | return $ret; | |||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | 0 | ▶ | sub getParsed { | ||||||||||||||||||||||||||
|
Subroutine
getParsed: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 304 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | return $self->setError (7641011, "OpenCA::CRL->getParsed: The CRL was not parsed.") | ||||||||||||||||||||||||||||
| 307 | 0 | ▶ | if ( not $self->{parsedItem} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 308 | 0 | return $self->{parsedItem}; | |||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | 0 | ▶ | sub getPEM { | ||||||||||||||||||||||||||
|
Subroutine
getPEM: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 312 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | 0 | ▶ | if ( $self->{crlFormat} eq 'PEM' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 315 | 0 | $self->{crl} =~ s/^\n*//; | |||||||||||||||||||||||||||
| 316 | 0 | $self->{crl} =~ s/\n*$/\n/; | |||||||||||||||||||||||||||
| 317 | 0 | return $self->{crl}; | |||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||
| 319 | 0 | ▶ | if (not $self->{pemCRL}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 320 | $self->{pemCRL} = $self->{backend}->dataConvert( DATA=>$self->{crl}, | ||||||||||||||||||||||||||||
| 321 | DATATYPE=>"CRL", | ||||||||||||||||||||||||||||
| 322 | INFORM=>$self->{crlFormat}, | ||||||||||||||||||||||||||||
| 323 | 0 | OUTFORM=>"PEM" ); | |||||||||||||||||||||||||||
| 324 | return $self->setError (7632011, "OpenCA::CRL->init: Cannot convert CRL to PEM-format ". | ||||||||||||||||||||||||||||
| 325 | "(".$OpenCA::OpenSSL::errno.")\n".$OpenCA::OpenSSL::errval) | ||||||||||||||||||||||||||||
| 326 | 0 | ▶ | if (not $self->{pemCRL}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | 0 | return $self->{pemCRL}; | |||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | 0 | ▶ | sub getDER { | ||||||||||||||||||||||||||
|
Subroutine
getDER: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 333 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | 0 | ▶ | if ( $self->{crlFormat} eq 'DER' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 336 | 0 | return $self->{crl}; | |||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||
| 338 | 0 | ▶ | if (not $self->{derCRL}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 339 | $self->{derCRL} = $self->{backend}->dataConvert( DATA=>$self->{crl}, | ||||||||||||||||||||||||||||
| 340 | DATATYPE=>"CRL", | ||||||||||||||||||||||||||||
| 341 | INFORM=>$self->{crlFormat}, | ||||||||||||||||||||||||||||
| 342 | 0 | OUTFORM=>"DER" ); | |||||||||||||||||||||||||||
| 343 | return $self->setError (7633011, "OpenCA::CRL->getDER: Cannot convert CRL to DER-format ". | ||||||||||||||||||||||||||||
| 344 | "(".$OpenCA::OpenSSL::errno.")\n".$OpenCA::OpenSSL::errval) | ||||||||||||||||||||||||||||
| 345 | 0 | ▶ | if (not $self->{derCRL}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | 0 | return $self->{derCRL}; | |||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | 0 | ▶ | sub getTXT { | ||||||||||||||||||||||||||
|
Subroutine
getTXT: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 352 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | 0 | ▶ | if (not $self->{txtCRL}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 355 | $self->{txtCRL} = $self->{backend}->dataConvert( DATA=>$self->{crl}, | ||||||||||||||||||||||||||||
| 356 | DATATYPE=>"CRL", | ||||||||||||||||||||||||||||
| 357 | INFORM=>$self->{crlFormat}, | ||||||||||||||||||||||||||||
| 358 | 0 | OUTFORM=>"TXT" ); | |||||||||||||||||||||||||||
| 359 | return $self->setError (7631011, "OpenCA::CRL->getTXT: Cannot convert CRL to TXT-format ". | ||||||||||||||||||||||||||||
| 360 | "(".$OpenCA::OpenSSL::errno.")\n".$OpenCA::OpenSSL::errval) | ||||||||||||||||||||||||||||
| 361 | 0 | ▶ | if (not $self->{txtCRL}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||
| 364 | 0 | return $self->{txtCRL}; | |||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | 0 | ▶ | sub getItem { | ||||||||||||||||||||||||||
|
Subroutine
getItem: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 368 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 369 | 0 | my $txtItem; | |||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | 0 | $txtItem = $self->{beginHeader}."\n"; | |||||||||||||||||||||||||||
| 372 | 0 | $txtItem .= $self->getHeader (); | |||||||||||||||||||||||||||
| 373 | 0 | $txtItem .= $self->{endHeader}."\n"; | |||||||||||||||||||||||||||
| 374 | 0 | $txtItem .= $self->getPEM (); | |||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | 0 | return $txtItem; | |||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | 0 | ▶ | sub getSerial { | ||||||||||||||||||||||||||
|
Subroutine
getSerial: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 380 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | 0 | return $self->{backend}->getDigest ( DATA => $self->getPEM() ); | |||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | 0 | ▶ | sub setParams { | ||||||||||||||||||||||||||
|
Subroutine
setParams: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 388 | 0 | my $params = { @_ }; | |||||||||||||||||||||||||||
| 389 | 0 | my $key; | |||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | 0 | foreach $key ( keys %{$params} ) { | |||||||||||||||||||||||||||
| 392 | ## we should place the parameters here | ||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | 0 | return 1; | |||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | # Below is the stub of documentation for your module. You better edit it! | ||||||||||||||||||||||||||||
| 399 | 1 | 1; | |||||||||||||||||||||||||||