OpenSSL/Key.pm

filter: Statementstmt 97.8% 45 / 46 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 100% 1 / 1 totaltotal 95.1% 59 / 62 SCAR 11.0
CC
3
Cov
94%
create
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
« OpenSSL/CertificateAuthority.pm ↑ Summary OpenSSL/Subject.pm »
1 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Tiny::OpenSSL::Key;
5  
6 # ABSTRACT: Key object.
7 4 our $VERSION = '0.1.1'; # VERSION
8  
9 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use Types::Standard qw( Str InstanceOf Int );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 ▶use Capture::Tiny qw( :all );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 4 ▶use Tiny::OpenSSL::Config qw($CONFIG);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 4 with 'Tiny::OpenSSL::Role::Entity';
17  
18 4 has password => ( is => 'rw', isa => Str );
19  
20 has bits =>
21 4 ▶ ( is => 'rw', isa => Int, default => sub { $CONFIG->{key}{bits} } );
Subroutine __ANON__: called CC=1 SCAR=0.0
22  
23 sub create {
24 4 ▶ my $self = shift;
Subroutine create: called CC=3 SCAR=11.1
Pod documented
25  
26 4 my @args = @{ $CONFIG->{key}{opts} };
27  
28 4 my $pass_file;
29  
30 4 ▶ if ( $self->password ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->password) 4 0 4
31 4 $pass_file = Path::Tiny->tempfile;
32  
33 4 $pass_file->spew( $self->password );
34  
35 4 push( @args, '-passout', sprintf( 'file:%s', $pass_file ) );
36 }
37  
38 4 push( @args, '-out', $self->file );
39 4 push( @args, $self->bits );
40  
41 my ( $stdout, $stderr, $exit ) = capture {
42 4 ▶ system( $CONFIG->{openssl}, @args );
Subroutine __ANON__: called CC=1 SCAR=0.0
43 4 };
44  
45 4 ▶ if ( $exit != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($exit != 0) 0 4 4
46 0 croak( sprintf( 'cannot create key: %s', $stderr ) );
47 }
48  
49 4 $self->ascii( $self->file->slurp );
50  
51 4 return 1;
52 }
53  
54 4 1;
55  
56 __END__
« OpenSSL/CertificateAuthority.pm ↑ Summary OpenSSL/Subject.pm »