Added ca config file creation from template and small bugfix

master
Thomas Hooge 4 years ago
parent a797cda27c
commit 1b49cf92c0
  1. 30
      lib/CA.pm
  2. 2
      lib/GUI.pm
  3. 1
      lib/KEY.pm
  4. 10
      templates/tinyca.cnf

@ -949,6 +949,25 @@ sub create_ca_env {
} }
close(OUT); close(OUT);
# create ca config file based on template
$in = $self->{'init'}->{'templatedir'}."/tinyca.cnf";
$out = $self->{$opts->{'name'}}->{'dir'}."/tinyca.cnf";
open(IN, "<$in") || do {
$t = sprintf(_("Can't open config template file %s %s"), $in, $!);
GUI::HELPERS::print_error($t);
return;
};
open(OUT, ">$out") || do {
$t = sprintf(_("Can't open config output file: %s: %s"),$out, $!);
GUI::HELPERS::print_error($t);
return;
};
while(<IN>) {
print OUT;
}
close(IN);
close(OUT);
if(defined($mode) && $mode eq "sub") { if(defined($mode) && $mode eq "sub") {
$self->create_ca($main, $opts, undef, $mode); $self->create_ca($main, $opts, undef, $mode);
} elsif(defined($mode) && $mode eq "import") { } elsif(defined($mode) && $mode eq "import") {
@ -1386,7 +1405,7 @@ sub export_crl {
sub _rm_dir { sub _rm_dir {
my $dir = shift; my $dir = shift;
my $dirh; my ($dirh, $path);
opendir($dirh, $dir); opendir($dirh, $dir);
@ -1394,13 +1413,14 @@ sub _rm_dir {
next if $f eq '.'; next if $f eq '.';
next if $f eq '..'; next if $f eq '..';
if(-d $dir."/".$f) { $path = $dir."/".$f;
_rm_dir($dir."/".$f); if(-d $path) {
_rm_dir($path);
} else { } else {
unlink($dir."/".$f); unlink($path);
} }
} }
closedir(DIR); closedir($dirh);
rmdir($dir); rmdir($dir);

@ -2731,7 +2731,7 @@ sub about {
} }
# #
# get confirmation for deleting a request # get confirmation for deleting a request, cert or key
# #
sub show_del_confirm { sub show_del_confirm {
my ($self, $file, $type) = @_; my ($self, $file, $type) = @_;

@ -452,6 +452,7 @@ sub _check_key {
return; return;
}; };
$type = "#ERR";
while(<KEY>) { while(<KEY>) {
if(/RSA PRIVATE KEY/i) { if(/RSA PRIVATE KEY/i) {
$type = "RSA"; $type = "RSA";

@ -0,0 +1,10 @@
[global]
use_metadb = no
default_req_type = user
default_domain = example.com
[server]
default_bits = 4096
[user]
default_bits = 2048