forked from virtualmin/virtualmin-gpl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default_cert.cgi
44 lines (35 loc) · 1.25 KB
/
default_cert.cgi
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
#!/usr/local/bin/perl
# Move all cert files to the default location
require './virtual-server-lib.pl';
&ReadParse();
$d = &get_domain($in{'dom'});
$d && &can_edit_domain($d) && &can_edit_ssl() ||
&error($text{'defaultcert_ecannot'});
$d->{'ssl_same'} && &error($text{'defaultcert_esame'});
&ui_print_unbuffered_header(&domain_in($d), $text{'defaultcert_title'}, "");
&lock_domain($d);
&obtain_lock_web($d);
@beforecerts = &get_all_domain_service_ssl_certs($d);
foreach my $t ("key", "cert", "ca", "combined", "everything") {
$deffile = &default_certificate_file($d, $t);
$desc = $text{'cert_type_'.$t};
&$first_print(&text('defaultcert_moving', $desc, "<tt>$deffile</tt>"));
if (&move_website_ssl_file($d, $t, $deffile)) {
&$second_print($text{'setup_done'});
}
else {
&$second_print($text{'defaultcert_none'});
}
}
# Update other services using the cert
&$first_print($text{'cert_updatesvcs'});
&update_all_domain_service_ssl_certs($d, \@beforecerts);
&$second_print($text{'setup_done'});
&run_post_actions();
&save_domain($d);
&release_lock_web($d);
&unlock_domain($d);
&webmin_log("defaultcert", "domain", $d->{'dom'}, $d);
&ui_print_footer("cert_form.cgi?dom=$d->{'id'}", $text{'cert_return'},
&domain_footer_link($d),
"", $text{'index_return'});