MOON
Server: Apache/2.2.31 (Unix) mod_ssl/2.2.31 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
System: Linux csr818.wilogic.com 2.6.18-419.el5xen #1 SMP Fri Feb 24 22:50:37 UTC 2017 x86_64
User: digitals (531)
PHP: 5.4.45
Disabled: NONE
Upload Files
File: //scripts.20110531.215904.25158/gencrt2
#!/usr/bin/perl

use IPC::Open2;          
use Sys::Hostname;
           $hostname = hostname();

@SSLLOC = ("/usr/bin/ssleay",
                "/usr/bin/openssl",
                "/usr/local/ssl/bin/ssleay",
                "/usr/local/ssl/bin/openssl");

foreach $sslloc (@SSLLOC) {
        if (-e $sslloc) { $ssl = $sslloc; }
}

@SSLLOC = ("/usr/local/ssl",
                "/var/ssl");

foreach $sslloc (@SSLLOC) {
        if (-e $sslloc) { $ssldir = $sslloc; }
}

#GenCRT script by cPanel, Inc.
print "[==========Generating a SSL Certif for a HTTPS=================]\n";
print "Before we begin please tell me where to e-mail the csr and key too-";
$xemail = <STDIN>;
$xemail =~ s/\n//g;
print "Enter the domainname to make a cert for? ";
$host = <STDIN>;
$host =~ s/\n//g;
print "=*=*=Cert info=*=*=\n";
print "Enter the Country Code (2 letters ie. US)? ";
$country = <STDIN>;
$country =~ s/\n//g;
print "Enter the State? ";
$state = <STDIN>;
$state =~ s/\n//g;
print "Enter the City? ";
$city = <STDIN>;
$city =~ s/\n//g;
print "Enter the Company Name? ";
$co = <STDIN>;
$co =~ s/\n//g;
print "Enter the Company Division? ";
$cod = <STDIN>;
$cod =~ s/\n//g;
print "Enter the Contact Email Address? ";
$email = <STDIN>;
$email =~ s/\n//g;

print "Enter a challenge password? ";
$pass = <STDIN>;
$pass =~ s/\n//g;


#-------------------------------------------

chdir("$ssldir/private");
open(KEY,">$host.key");
open(SSL,"$ssl genrsa 1024|");
while(<SSL>) {
	print KEY $_;
}
close(SSL);
close(KEY);



open(SENDMAIL,"|/usr/sbin/sendmail -t");
#print SENDMAIL "To: sslmaster\@darkorb.net\n";
print SENDMAIL "To: $xemail\n";
print SENDMAIL "From: ssl\@$hostname\n";
print SENDMAIL "Subject: SSL RSA PRIVATE KEY for $host\n\n";
print SENDMAIL<<EOM;
$country
$state
$city
$co
$cod
$host
$email

challenge password: $pass
========================================================
EOM
open(KEY,"$host.key");
while (<KEY>) { print SENDMAIL $_ }
close(KEY);
close(SENDMAIL);


#---------------------------
chdir("$ssldir/certs");
open2(\*CERT,\*SSL,"$ssl req -new -key ../private/$host.key -out $host.csr");
print SSL<<EOM;
$country
$state
$city
$co
$cod
$host
$email
$password
$co
EOM
open(CSR,">$host.csr");
while(<CERT>) {
	print CSR $_;
}
close(CSR);
close(SSL);
close(CERT);

open(SENDMAIL,"|/usr/sbin/sendmail -t");
#print SENDMAIL "To: sslmaster\@darkorb.net\n";
print SENDMAIL "To: $xemail\n";
print SENDMAIL "From: ssl\@$hostname\n";
print SENDMAIL "Subject: SSL CERTIFICATE SIGNING REQUEST for $host\n\n";
open(KEY,"$host.csr");
while (<KEY>) { print SENDMAIL $_ }
close(KEY);
close(SENDMAIL);

#--------------------------------------
open2(\*CERT,\*SSL,"$ssl req -new -x509 -key ../private/$host.key");
print SSL<<EOM;
$country
$state
$city
$co
$cod
$host
$email
EOM
open(CRT,">$host.crt");
while(<CERT>) {
	print CRT $_;
}
close(CST);
close(SSL);
close(CERT);