Private
Server IP : 195.201.23.43  /  Your IP : 3.137.210.249
Web Server : Apache
System : Linux webserver2.vercom.be 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64
User : kdecoratie ( 1041)
PHP Version : 7.1.33-63+ubuntu20.04.1+deb.sury.org+1
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/webmin/virtual-server/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /usr/share/webmin/virtual-server/list-certs.pl
#!/usr/bin/perl

=head1 list-certs.pl

Output the certificates for some or all virtual servers.

The virtual servers to list can be selected with the C<--domain> flag
followed by a domain name, or C<--user> followed by an administrator's
username - both of which can be given multiple times. Or you can use 
C<--all-domains> to find certificates for every virtual server with SSL
enabled.

By default, all known certificates and keys are output. However, you can
limit the results to particular certificates with one of more of the
following flags :

C<--cert> - SSL certificate only

C<--key> - SSL private key

C<--ca> - SSL chained CA certificate, if there is one

C<--csr> - SSL certificate signing request, for sending to a CA

C<--newkey> - SSL private key matching the CSR, but not yet installed

=cut

package virtual_server;
if (!$module_name) {
	$main::no_acl_check++;
	$ENV{'WEBMIN_CONFIG'} ||= "/etc/webmin";
	$ENV{'WEBMIN_VAR'} ||= "/var/webmin";
	if ($0 =~ /^(.*)\/[^\/]+$/) {
		chdir($pwd = $1);
		}
	else {
		chop($pwd = `pwd`);
		}
	$0 = "$pwd/list-certs.pl";
	require './virtual-server-lib.pl';
	$< == 0 || die "list-certs.pl must be run as root";
	}

# Parse command line to get domains
@alltypes = ( "cert", "key", "ca", "csr", "newkey" );
while(@ARGV > 0) {
	local $a = shift(@ARGV);
	if ($a eq "--domain") {
		push(@dnames, shift(@ARGV));
		}
	elsif ($a eq "--user") {
		push(@users, shift(@ARGV));
		}
	elsif ($a eq "--all-domains") {
		$all = 1;
		}
	elsif ($a eq "--cert" || $a eq "--key" || $a eq "--ca" ||
	       $a eq "--csr" || $a eq "--newkey") {
		push(@types, substr($a, 2));
		}
	elsif ($a eq "--multiline") {
		$multiline = 1;
		}
	elsif ($a eq "--help") {
		&usage();
		}
	else {
		&usage("Unknown parameter $a");
		}
	}

# Get the domains
@dnames || @users || $all || &usage("No domains or users specified");
if ($all) {
	@doms = &list_domains();
	}
else {
	@doms = &get_domains_by_names_users(\@dnames, \@users, \&usage);
	}
@doms || &usage("No virtual servers matching the domain names and usernames ".
		"given were found");
@doms = grep { &domain_has_ssl_cert($_) } @doms;
@doms || &usage("None of the specified virtual servers have an SSL cert");
if (!@types) {
	@types = @alltypes;
	}

# Output the certs
foreach $d (@doms) {
	foreach $t (@types) {
		$data = $d->{'ssl_'.$t} ? &read_file_contents($d->{'ssl_'.$t})
					: undef;
		if ($data) {
			print "$d->{'dom'}:\n";
			print "    Type: $t\n";
			print "    File: ",$d->{'ssl_'.$t},"\n";
			$data =~ s/\s*$//g;
			$data .= "\n";
			print $data;
			}
		}
	}

sub usage
{
print "$_[0]\n\n" if ($_[0]);
print "Outputs the certificates and keys for one or more virtual servers.\n";
print "\n";
print "virtualmin list-certs --all-domains | --domain name | --user username\n";
print "                     [".join(" | ", map { "--".$_ } @alltypes)."]\n";
exit(1);
}

Private