line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
1022
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
71
|
|
2
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
105
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Tiny::OpenSSL::Certificate; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: X509 Certificate Object. |
7
|
|
|
|
|
|
|
our $VERSION = '0.1.2'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
11
|
use Moo; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
15
|
|
10
|
2
|
|
|
2
|
|
615
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
153
|
|
11
|
2
|
|
|
2
|
|
11
|
use Types::Standard qw( InstanceOf ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
35
|
|
12
|
2
|
|
|
2
|
|
1133
|
use Tiny::OpenSSL::Config qw($CONFIG); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
205
|
|
13
|
2
|
|
|
2
|
|
12
|
use Capture::Tiny qw( :all ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
831
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
with 'Tiny::OpenSSL::Role::Entity'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has [qw(issuer subject)] => |
18
|
|
|
|
|
|
|
( is => 'rw', isa => InstanceOf ['Tiny::OpenSSL::Subject'] ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has key => ( is => 'rw', isa => InstanceOf ['Tiny::OpenSSL::Key'] ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub self_sign { |
23
|
|
|
|
|
|
|
|
24
|
2
|
|
|
2
|
1
|
867
|
my $self = shift; |
25
|
2
|
|
|
|
|
5
|
my $csr = shift; |
26
|
|
|
|
|
|
|
|
27
|
2
|
50
|
|
|
|
9
|
if ( !defined $csr ) { |
28
|
0
|
|
|
|
|
0
|
croak 'csr is not defined'; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
|
|
20
|
my @args = ( |
32
|
|
|
|
|
|
|
'x509', '-req', '-days', $CONFIG->{ca}{days}, |
33
|
|
|
|
|
|
|
'-in', $csr->file, '-signkey', $self->key->file, |
34
|
|
|
|
|
|
|
'-out', $self->file |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
2
|
|
|
|
|
689
|
my $pass_file; |
38
|
|
|
|
|
|
|
|
39
|
2
|
50
|
|
|
|
39
|
if ( $csr->key->password ) { |
40
|
|
|
|
|
|
|
|
41
|
2
|
|
|
|
|
69
|
$pass_file = Path::Tiny->tempfile; |
42
|
2
|
|
|
|
|
931
|
$pass_file->spew( $self->key->password ); |
43
|
|
|
|
|
|
|
|
44
|
2
|
|
|
|
|
706
|
push( @args, '-passin', sprintf( 'file:%s', $pass_file ) ); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my ( $stdout, $stderr, $exit ) = capture { |
49
|
2
|
|
|
2
|
|
24293
|
system( $CONFIG->{openssl}, @args ); |
50
|
2
|
|
|
|
|
75
|
}; |
51
|
|
|
|
|
|
|
|
52
|
2
|
50
|
|
|
|
1823
|
if ( $exit != 0 ) { |
53
|
0
|
|
|
|
|
0
|
croak( sprintf( 'cannot sign certificate: %s', $stderr ) ); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
2
|
|
|
|
|
82
|
$self->issuer( $self->subject ); |
57
|
2
|
|
|
|
|
2240
|
$self->ascii( $self->file->slurp ); |
58
|
|
|
|
|
|
|
|
59
|
2
|
|
|
|
|
608
|
return 1; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |