Skip to content

Commit

Permalink
Do the same thing with the SSL cert for Nginx restores that we do for…
Browse files Browse the repository at this point in the history
… Apache restores
  • Loading branch information
jcameron committed Mar 12, 2023
1 parent 123b087 commit 2e3d9c2
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions virtual_feature.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2584,24 +2584,28 @@ sub feature_restore
&$virtual_server::second_print($virtual_server::text{'setup_done'});
}

# Restore SSL cert and key
my $cert = $d->{'ssl_cert'} || &feature_get_web_ssl_file($d, 'cert');
my $key = $d->{'ssl_key'} || &feature_get_web_ssl_file($d, 'key');
my $ca = $d->{'ssl_chain'} || &feature_get_web_ssl_file($d, 'ca');
if ($cert && -r $file."_cert") {
&lock_file($cert);
&virtual_server::write_ssl_file_contents($d, $cert, $file."_cert");
&unlock_file($cert);
}
if ($key && -r $file."_key") {
&lock_file($key);
&virtual_server::write_ssl_file_contents($d, $key, $file."_key");
&unlock_file($key);
}
if ($ca && -r $file."_ca") {
&lock_file($ca);
&virtual_server::write_ssl_file_contents($d, $ca, $file."_ca");
&unlock_file($ca);
# Restore SSL cert and key, unless shared
if (!$d->{'ssl_same'}) {
my $cert = $d->{'ssl_cert'} || &feature_get_web_ssl_file($d, 'cert');
my $key = $d->{'ssl_key'} || &feature_get_web_ssl_file($d, 'key');
my $ca = $d->{'ssl_chain'} || &feature_get_web_ssl_file($d, 'ca');
if ($cert && -r $file."_cert") {
&lock_file($cert);
&virtual_server::write_ssl_file_contents($d, $cert, $file."_cert");
&unlock_file($cert);
}
if ($key && -r $file."_key") {
&lock_file($key);
&virtual_server::write_ssl_file_contents($d, $key, $file."_key");
&unlock_file($key);
}
if ($ca && -r $file."_ca") {
&lock_file($ca);
&virtual_server::write_ssl_file_contents($d, $ca, $file."_ca");
&unlock_file($ca);
}
&virtual_server::refresh_ssl_cert_expiry($d);
&virtual_server::sync_combined_ssl_cert($d);
}

return 1;
Expand Down

0 comments on commit 2e3d9c2

Please sign in to comment.