line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
837
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
64
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Tiny::OpenSSL::CertificateAuthority; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Certificate Authority object. |
7
|
|
|
|
|
|
|
our $VERSION = '0.1.3'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
4
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
10
|
1
|
|
|
1
|
|
337
|
use Carp qw(croak); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
71
|
|
11
|
1
|
|
|
1
|
|
5
|
use Capture::Tiny qw( :all ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
175
|
|
12
|
1
|
|
|
1
|
|
6
|
use Tiny::OpenSSL::Config qw($CONFIG); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
357
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
extends 'Tiny::OpenSSL::Certificate'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub sign { |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
19
|
0
|
|
|
|
|
|
my $csr = shift; |
20
|
0
|
|
|
|
|
|
my $crt = shift; |
21
|
|
|
|
|
|
|
|
22
|
0
|
0
|
|
|
|
|
if ( !defined $csr ) { |
23
|
0
|
|
|
|
|
|
croak '$csr is not defined'; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
0
|
0
|
|
|
|
|
if ( !defined $crt ) { |
27
|
0
|
|
|
|
|
|
croak '$crt is not defined'; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my @args = ( |
31
|
|
|
|
|
|
|
'ca', '-policy', |
32
|
|
|
|
|
|
|
'policy_anything', '-batch', |
33
|
|
|
|
|
|
|
'-cert', $crt->file, |
34
|
|
|
|
|
|
|
'-keyfile', $self->key->file, |
35
|
|
|
|
|
|
|
'-in', $csr->file, |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $pass_file; |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
if ( $self->key->password ) { |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
$pass_file = Path::Tiny->tempfile; |
43
|
0
|
|
|
|
|
|
$pass_file->spew( $self->key->password ); |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
push( @args, '-passin', sprintf( 'file:%s', $pass_file ) ); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my ( $stdout, $stderr, $exit ) = capture { |
50
|
0
|
|
|
0
|
|
|
system( $CONFIG->{openssl}, @args ); |
51
|
0
|
|
|
|
|
|
}; |
52
|
|
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
if ( $exit != 0 ) { |
54
|
0
|
|
|
|
|
|
croak( sprintf( 'cannot sign certificate: %s', $stderr ) ); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$crt->issuer( $self->subject ); |
58
|
0
|
|
|
|
|
|
$crt->ascii( $crt->file->slurp ); |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return 1; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |