line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
1144
|
use strict; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
120
|
|
2
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
123
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Tiny::OpenSSL::CertificateSigningRequest; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Certificate Signing Request object. |
7
|
|
|
|
|
|
|
our $VERSION = '0.1.2'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
11
|
use Carp; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
194
|
|
10
|
3
|
|
|
3
|
|
12
|
use Moo; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
13
|
|
11
|
3
|
|
|
3
|
|
751
|
use Types::Standard qw( InstanceOf ); |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
30
|
|
12
|
3
|
|
|
3
|
|
1124
|
use Path::Tiny; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
146
|
|
13
|
3
|
|
|
3
|
|
11
|
use Capture::Tiny qw( :all ); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
369
|
|
14
|
3
|
|
|
3
|
|
13
|
use Tiny::OpenSSL::Config qw($CONFIG); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
818
|
|
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
|
3
|
|
|
3
|
1
|
3459
|
my $self = shift; |
29
|
|
|
|
|
|
|
|
30
|
3
|
|
|
|
|
9
|
my @args = @{ $CONFIG->{req}{opts} }; |
|
3
|
|
|
|
|
38
|
|
31
|
|
|
|
|
|
|
|
32
|
3
|
|
|
|
|
11
|
push @args, '-new'; |
33
|
3
|
|
|
|
|
20
|
push @args, '-subj', $self->subject->dn; |
34
|
3
|
|
|
|
|
17
|
push @args, '-key', $self->key->file; |
35
|
|
|
|
|
|
|
|
36
|
3
|
|
|
|
|
1881
|
my $pass_file; |
37
|
|
|
|
|
|
|
|
38
|
3
|
50
|
|
|
|
60
|
if ( $self->key->password ) { |
39
|
3
|
|
|
|
|
117
|
$pass_file = Path::Tiny->tempfile; |
40
|
3
|
|
|
|
|
1494
|
$pass_file->spew( $self->key->password ); |
41
|
3
|
|
|
|
|
1226
|
push( @args, '-passin', sprintf( 'file:%s', $pass_file ) ); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
3
|
|
|
|
|
32
|
push @args, '-out', $self->file; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my ( $stdout, $stderr, $exit ) = capture { |
47
|
3
|
|
|
3
|
|
37251
|
system( $CONFIG->{openssl}, @args ); |
48
|
3
|
|
|
|
|
186
|
}; |
49
|
|
|
|
|
|
|
|
50
|
3
|
50
|
|
|
|
2483
|
if ( $exit != 0 ) { |
51
|
0
|
|
|
|
|
0
|
croak( sprintf( 'cannot create csr: %s', $stderr ) ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
3
|
|
|
|
|
41
|
$self->ascii( $self->file->slurp ); |
55
|
|
|
|
|
|
|
|
56
|
3
|
|
|
|
|
947
|
return 1; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |