OpenSSL/CertificateAuthority.pm

filter: Statementstmt 89.1% 33 / 37 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 100% 2 / 2 totaltotal 86.5% 45 / 52 SCAR 11.1
CC
3
Cov
85%
self_sign
3.1
sign
2.0
BEGIN
1.0
CRAP 3.0
↑ Summary OpenSSL/Key.pm »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Tiny::OpenSSL::CertificateAuthority;
5  
6 # ABSTRACT: Certificate Authority object.
7 1 our $VERSION = '0.1.1'; # VERSION
8  
9 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Capture::Tiny qw( :all );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Tiny::OpenSSL::Config qw($CONFIG);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 extends 'Tiny::OpenSSL::Certificate';
15  
16 sub sign {
17 0 ▶ my $self = shift;
Subroutine sign: not called CC=1 SCAR=6.9
Pod documented
18  
19 0 return 1;
20 }
21  
22 sub self_sign {
23  
24 1 ▶ my $self = shift;
Subroutine self_sign: called CC=3 SCAR=11.3
Pod documented
25 1 my $csr = shift;
26  
27 1 ▶ if ( !defined $csr ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $csr) 0 1 1
28 0 croak 'csr is not defined';
29 }
30  
31 1 my $pass_file = Path::Tiny->tempfile;
32 1 $pass_file->spew( $self->key->password );
33  
34 my @args = (
35 'x509', '-req',
36 '-days', $CONFIG->{ca}{days},
37 1 '-in', $csr->file,
38 '-signkey', $self->key->file,
39 '-passin', sprintf( 'file:%s', $pass_file ),
40 '-out', $self->file
41 );
42  
43 my ( $stdout, $stderr, $exit ) = capture {
44 1 ▶ system( $CONFIG->{openssl}, @args );
Subroutine __ANON__: called CC=1 SCAR=0.0
45 1 };
46  
47 1 ▶ if ( $exit != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($exit != 0) 0 1 1
48 0 croak( sprintf( 'cannot sign certificate: %s', $stderr ) );
49 }
50  
51 1 $self->issuer( $self->subject );
52 1 $self->ascii( $self->file->slurp );
53  
54 1 return 1;
55 }
56  
57 1 1;
58  
59 __END__
↑ Summary OpenSSL/Key.pm »