line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
590
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
2
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Tiny::OpenSSL::CertificateAuthority; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Certificate Authority object. |
7
|
|
|
|
|
|
|
our $VERSION = '0.1.1'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
4
|
use Moo; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
10
|
1
|
|
|
1
|
|
278
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
72
|
|
11
|
1
|
|
|
1
|
|
4
|
use Capture::Tiny qw( :all ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
158
|
|
12
|
1
|
|
|
1
|
|
5
|
use Tiny::OpenSSL::Config qw($CONFIG); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
304
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
extends 'Tiny::OpenSSL::Certificate'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub sign { |
17
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
0
|
return 1; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub self_sign { |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
1
|
1053
|
my $self = shift; |
25
|
1
|
|
|
|
|
2
|
my $csr = shift; |
26
|
|
|
|
|
|
|
|
27
|
1
|
50
|
|
|
|
11
|
if ( !defined $csr ) { |
28
|
0
|
|
|
|
|
0
|
croak 'csr is not defined'; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
15
|
my $pass_file = Path::Tiny->tempfile; |
32
|
1
|
|
|
|
|
768
|
$pass_file->spew( $self->key->password ); |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
1282
|
my @args = ( |
35
|
|
|
|
|
|
|
'x509', '-req', |
36
|
|
|
|
|
|
|
'-days', $CONFIG->{ca}{days}, |
37
|
|
|
|
|
|
|
'-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
|
|
|
1
|
|
25640
|
system( $CONFIG->{openssl}, @args ); |
45
|
1
|
|
|
|
|
251
|
}; |
46
|
|
|
|
|
|
|
|
47
|
1
|
50
|
|
|
|
1149
|
if ( $exit != 0 ) { |
48
|
0
|
|
|
|
|
0
|
croak( sprintf( 'cannot sign certificate: %s', $stderr ) ); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
27
|
$self->issuer( $self->subject ); |
52
|
1
|
|
|
|
|
2042
|
$self->ascii( $self->file->slurp ); |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
392
|
return 1; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |