line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
1826
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
98
|
|
2
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
161
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Tiny::OpenSSL::Certificate; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: X509 Certificate Object. |
7
|
|
|
|
|
|
|
our $VERSION = '0.1.3'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
15
|
use Moo; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
25
|
|
10
|
3
|
|
|
3
|
|
894
|
use Carp; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
193
|
|
11
|
3
|
|
|
3
|
|
15
|
use Types::Standard qw( InstanceOf ); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
44
|
|
12
|
3
|
|
|
3
|
|
1599
|
use Tiny::OpenSSL::Config qw($CONFIG); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
291
|
|
13
|
3
|
|
|
3
|
|
13
|
use Capture::Tiny qw( :all ); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1355
|
|
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
|
3
|
|
|
3
|
1
|
1081
|
my $self = shift; |
25
|
3
|
|
|
|
|
16
|
my $csr = shift; |
26
|
|
|
|
|
|
|
|
27
|
3
|
50
|
|
|
|
19
|
if ( !defined $csr ) { |
28
|
0
|
|
|
|
|
0
|
croak 'csr is not defined'; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my @args = ( |
32
|
|
|
|
|
|
|
'x509', '-req', '-days', $CONFIG->{ca}{days}, |
33
|
3
|
|
|
|
|
56
|
'-in', $csr->file, '-signkey', $self->key->file, |
34
|
|
|
|
|
|
|
'-out', $self->file |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
3
|
|
|
|
|
1071
|
my $pass_file; |
38
|
|
|
|
|
|
|
|
39
|
3
|
100
|
|
|
|
113
|
if ( $csr->key->password ) { |
40
|
|
|
|
|
|
|
|
41
|
2
|
|
|
|
|
86
|
$pass_file = Path::Tiny->tempfile; |
42
|
2
|
|
|
|
|
1130
|
$pass_file->spew( $self->key->password ); |
43
|
|
|
|
|
|
|
|
44
|
2
|
|
|
|
|
996
|
push( @args, '-passin', sprintf( 'file:%s', $pass_file ) ); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my ( $stdout, $stderr, $exit ) = capture { |
49
|
3
|
|
|
3
|
|
233108
|
system( $CONFIG->{openssl}, @args ); |
50
|
3
|
|
|
|
|
214
|
}; |
51
|
|
|
|
|
|
|
|
52
|
3
|
50
|
|
|
|
5622
|
if ( $exit != 0 ) { |
53
|
0
|
|
|
|
|
0
|
croak( sprintf( 'cannot sign certificate: %s', $stderr ) ); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
3
|
|
|
|
|
189
|
$self->issuer( $self->subject ); |
57
|
3
|
|
|
|
|
7870
|
$self->ascii( $self->file->slurp ); |
58
|
|
|
|
|
|
|
|
59
|
3
|
|
|
|
|
1888
|
return 1; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |