line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
1197
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
92
|
|
2
|
3
|
|
|
3
|
|
10
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
123
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Tiny::OpenSSL::CertificateSigningRequest; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Certificate Signing Request object. |
7
|
|
|
|
|
|
|
our $VERSION = '0.1.1'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
13
|
use Carp; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
166
|
|
10
|
3
|
|
|
3
|
|
13
|
use Moo; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
13
|
|
11
|
3
|
|
|
3
|
|
720
|
use Types::Standard qw( InstanceOf ); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
23
|
|
12
|
3
|
|
|
3
|
|
1139
|
use Path::Tiny; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
146
|
|
13
|
3
|
|
|
3
|
|
13
|
use Capture::Tiny qw( :all ); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
410
|
|
14
|
3
|
|
|
3
|
|
16
|
use Tiny::OpenSSL::Config qw($CONFIG); |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
965
|
|
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
|
2
|
|
|
2
|
1
|
2044
|
my $self = shift; |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
|
|
61
|
my @args = @{ $CONFIG->{req}{opts} }; |
|
2
|
|
|
|
|
18
|
|
31
|
|
|
|
|
|
|
|
32
|
2
|
|
|
|
|
10
|
push @args, '-subj', $self->subject->dn; |
33
|
2
|
|
|
|
|
14
|
push @args, '-key', $self->key->file; |
34
|
|
|
|
|
|
|
|
35
|
2
|
|
|
|
|
1313
|
my $pass_file = Path::Tiny->tempfile; |
36
|
2
|
|
|
|
|
1297
|
$pass_file->spew( $self->key->password ); |
37
|
|
|
|
|
|
|
|
38
|
2
|
|
|
|
|
917
|
push( @args, '-passin', sprintf( 'file:%s', $pass_file ) ); |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
22
|
push @args, '-out', $self->file; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my ( $stdout, $stderr, $exit ) = capture { |
43
|
2
|
|
|
2
|
|
78762
|
system( $CONFIG->{openssl}, @args ); |
44
|
2
|
|
|
|
|
129
|
}; |
45
|
|
|
|
|
|
|
|
46
|
2
|
50
|
|
|
|
1467
|
if ( $exit != 0 ) { |
47
|
0
|
|
|
|
|
0
|
croak( sprintf( 'cannot create csr: %s', $stderr ) ); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
2
|
|
|
|
|
20
|
$self->ascii( $self->file->slurp ); |
51
|
|
|
|
|
|
|
|
52
|
2
|
|
|
|
|
618
|
return 1; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |