line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
2419
|
use strict; |
|
4
|
|
|
|
|
47
|
|
|
4
|
|
|
|
|
98
|
|
2
|
4
|
|
|
4
|
|
18
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
195
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Tiny::OpenSSL::CertificateSigningRequest; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Certificate Signing Request object. |
7
|
|
|
|
|
|
|
our $VERSION = '0.1.3'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
18
|
use Carp; |
|
4
|
|
|
|
|
24
|
|
|
4
|
|
|
|
|
278
|
|
10
|
4
|
|
|
4
|
|
19
|
use Moo; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
30
|
|
11
|
4
|
|
|
4
|
|
1109
|
use Types::Standard qw( InstanceOf ); |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
36
|
|
12
|
4
|
|
|
4
|
|
2017
|
use Path::Tiny; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
191
|
|
13
|
4
|
|
|
4
|
|
19
|
use Capture::Tiny qw( :all ); |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
644
|
|
14
|
4
|
|
|
4
|
|
20
|
use Tiny::OpenSSL::Config qw($CONFIG); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
1383
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
with 'Tiny::OpenSSL::Role::Entity'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has subject => ( |
19
|
|
|
|
|
|
|
is => 'rw', |
20
|
|
|
|
|
|
|
isa => InstanceOf ['Tiny::OpenSSL::Subject'], |
21
|
|
|
|
|
|
|
required => 1 |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has key => |
25
|
|
|
|
|
|
|
( is => 'rw', isa => InstanceOf ['Tiny::OpenSSL::Key'], required => 1 ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub create { |
28
|
4
|
|
|
4
|
1
|
4493
|
my $self = shift; |
29
|
|
|
|
|
|
|
|
30
|
4
|
|
|
|
|
108
|
my @args = @{ $CONFIG->{req}{opts} }; |
|
4
|
|
|
|
|
54
|
|
31
|
|
|
|
|
|
|
|
32
|
4
|
|
|
|
|
17
|
push @args, '-new'; |
33
|
4
|
|
|
|
|
31
|
push @args, '-subj', $self->subject->dn; |
34
|
4
|
|
|
|
|
30
|
push @args, '-key', $self->key->file; |
35
|
|
|
|
|
|
|
|
36
|
4
|
|
|
|
|
2515
|
my $pass_file; |
37
|
|
|
|
|
|
|
|
38
|
4
|
100
|
|
|
|
88
|
if ( $self->key->password ) { |
39
|
3
|
|
|
|
|
126
|
$pass_file = Path::Tiny->tempfile; |
40
|
3
|
|
|
|
|
1712
|
$pass_file->spew( $self->key->password ); |
41
|
3
|
|
|
|
|
1635
|
push( @args, '-passin', sprintf( 'file:%s', $pass_file ) ); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
4
|
|
|
|
|
68
|
push @args, '-out', $self->file; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my ( $stdout, $stderr, $exit ) = capture { |
47
|
4
|
|
|
4
|
|
100031
|
system( $CONFIG->{openssl}, @args ); |
48
|
4
|
|
|
|
|
289
|
}; |
49
|
|
|
|
|
|
|
|
50
|
4
|
50
|
|
|
|
7797
|
if ( $exit != 0 ) { |
51
|
0
|
|
|
|
|
0
|
croak( sprintf( 'cannot create csr: %s', $stderr ) ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
4
|
|
|
|
|
224
|
$self->ascii( $self->file->slurp ); |
55
|
|
|
|
|
|
|
|
56
|
4
|
|
|
|
|
2976
|
return 1; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |