File Coverage

blib/lib/Crypt/Bear/X509/PrivateKey.pm
Criterion Covered Total %
statement 20 20 100.0
branch 2 4 50.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 28 30 93.3


line stmt bran cond sub pod time code
1             package Crypt::Bear::X509::PrivateKey;
2             $Crypt::Bear::X509::PrivateKey::VERSION = '0.004';
3 3     3   158094 use strict;
  3         5  
  3         91  
4 3     3   10 use warnings;
  3         3  
  3         142  
5              
6 3     3   296 use Crypt::Bear;
  3         4  
  3         56  
7 3     3   368 use Crypt::Bear::PEM;
  3         4  
  3         547  
8              
9             sub load {
10 1     1 1 4 my ($class, $filename) = @_;
11              
12 1 50       52 open my $fh, '<:crlf', $filename or die "Could not open certificate $filename: $!";
13 1         3 my $raw = do { local $/; <$fh> };
  1         5  
  1         40  
14 1         1251 my ($banner, $content) = Crypt::Bear::PEM::pem_decode($raw);
15 1 50       9 die "File $filename does not contain a private key" unless $banner =~ /PRIVATE KEY/;
16              
17 1         627 return $class->new($content);
18             }
19              
20             1;
21              
22             #ABSTRACT: A X509 private key
23              
24             __END__