OpenSSL/CertificateSigningRequest.pm

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