Renew cert: get default valid days

master
Thomas Hooge 3 years ago
parent 2d76d96647
commit 674e1f6a67
  1. 16
      lib/CERT.pm

@ -128,7 +128,7 @@ sub read_certlist {
sub get_renew_cert {
my ($self, $main, $opts, $box) = @_;
my ($cert, $status, $t, $ca, $cadir);
my ($cert, $status, $t, $ca, $cadir, $parsed, $time);
$box->destroy() if(defined($box));
@ -170,6 +170,20 @@ sub get_renew_cert {
return;
}
# get default for valid days
$parsed = $main->{'CERT'}->parse_cert($main, 'CA');
defined($parsed) ||
GUI::HELPERS::print_error(_("Can't read CA certificate"));
$opts->{'days'} =
$main->{'TCONFIG'}->{$opts->{'type'}."_ca"}->{'default_days'};
$time = time();
if($opts->{'days'} > (($parsed->{'EXPDATE'}/86400) - ($time/86400))) {
$opts->{'days'} = int(($parsed->{'EXPDATE'}/86400) - ($time/86400));
}
$main->show_req_sign_dialog($opts);
return;
}