Created
July 1, 2010 01:05
-
-
Save anonymous/459414 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$key = $_SERVER['argv'][1]; | |
$domain = $_SERVER['argv'][2]; | |
$path = "/Users/adrian/test/" . $key; | |
if (!is_dir($path)) { | |
mkdir($path); | |
} | |
$pass = 'pass'; | |
// generate a key | |
$cmd[] = sprintf('openssl genrsa -passout pass:%s -des3 -out %s/openssl.key.orig 1024', $pass, $path); | |
// unsign it | |
$cmd[] = sprintf('openssl rsa -passin pass:%s -in %s/openssl.key.orig -out %s/openssl.key', $pass, $path, $path); | |
$input = "/C=za/CN=$domain/OU=$domain/emailAddress=admin@$domain"; | |
// Generate the CSR | |
$cmd[] = sprintf("openssl req -new -subj '%s' -key %s/openssl.key -out %s/openssl.csr -batch", $input, $path, $path); | |
$cmd[] = sprintf("openssl x509 -req -days 365 -in %s/openssl.csr -signkey %s/openssl.key -out %s/openssl.crt", $path, $path, $path); | |
foreach ($cmd as $command) { | |
echo $command . "\n"; | |
system($command); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment