-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-root-ca
More file actions
executable file
·44 lines (33 loc) · 1.02 KB
/
create-root-ca
File metadata and controls
executable file
·44 lines (33 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use Log::Any::App '$log';
use Log::Any::For::Builtins qw(system);
use Perinci::CmdLine::Any;
our %SPEC;
$SPEC{create_root_ca} = {
v => 1.1,
summary => 'Create your own root CA to sign certificate with',
args => {
name => {
schema => ['str*' => match => qr/\A\w+\z/],
},
},
deps => {
exec => 'openssl',
},
};
sub create_root_ca {
my %args = @_;
my $fr = (defined($args{name}) ? "$args{name}-" : ""). "ca";
#my $fi = (defined($args{name}) ? "$args{name}-" : ""). "ia";
# create root CA
system("openssl genrsa -out $fr.key 4096");
system("openssl req -new -x509 -days 3650 -key $fr.key -out $fr.crt");
# create intermediate CA to be used for actual signing
#system("openssl genrsa -out $fi.key 4096");
#system("openssl x509 -req -days 3650 -in $fi.csr -CA $fr.crt -CAkey $fr.key -set_serial 01 -out $fi.crt");
[200];
}
Perinci::CmdLine::Any->new(url => '/main/create_root_ca')->run;