perl<<'EOF'
use strict;
use YAML::XS qw(LoadFile);

my $domain = 'domain_placeholder';

my $user;
my $found = 0;
open(my $f, '<', '/etc/userdomains');
	while(<$f>) {
		if ( /^$domain:\s(.*)$/ ) {
			$user = $1;
			if ( -f '/var/cpanel/userdata/' . $user . '/' . $domain . '_SSL' ) {
				$found = 1;
				my ( $config ) = LoadFile('/var/cpanel/userdata/' . $user . '/' . $domain . '_SSL');
				print '[*] SSL found on [' . $domain . ']:' . "\n";
				print "\t" . get_data($config->{'sslcertificatefile'}, 'subject') . "\n";
				print "\t" . get_data($config->{'sslcertificatefile'}, 'issuer') . "\n";
				print "\t" . get_data($config->{'sslcertificatefile'}, 'startdate') . "\n";
				print "\t" . get_data($config->{'sslcertificatefile'}, 'enddate') . "\n";
				print "\t" . 'alternates=' . get_alternates($config->{'sslcertificatefile'}) . "\n";
				print "\t" . 'isDedicatedIp=' . is_dedicated($domain) . "\n";
			}
		}
	}
close($f);
die '[*] No account found on this server.' . "\n" unless $user;
die '[*] No SSLs found on the account [' . $user . ']' . "\n" unless $found;

sub get_data {
	my $cert = shift;
	my $item = shift;
	chomp(my $output = `openssl x509 -$item -noout -in $cert`);
	return($output);
}

sub get_alternates {
	my $cert = shift;
	chomp(my $alternates = `openssl x509 -text -noout -in $cert |grep DNS`);
	$alternates =~ s/^\s+//g;
    $alternates =~ s/DNS://g;
	return($alternates);
}

sub is_dedicated {
	my $domain = shift;
	open(my $f, '<', '/etc/domainips');
		while(<$f>) {
			if ( /^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}: $domain$/ ) {
				return('True');
			}
		}
	close($f);
	return('False');
}
EOF