This commit is contained in:
加里
2014-08-11 16:43:14 +08:00
parent 5e269eac91
commit 7eea58952b
14 changed files with 367 additions and 254 deletions

View File

@@ -2,6 +2,7 @@
#Required
domain=$1
outputPath=$2
commonname=$domain
#Change to your company details
@@ -15,7 +16,7 @@ email=a@b.com
#Optional
password=a
if [ -z "$domain" ]
if [ -z "$outputPath$domain" ]
then
echo "Argument not present."
echo "Useage $0 [common name]"
@@ -23,25 +24,25 @@ then
exit 99
fi
echo "Generating key request for $domain"
echo "Generating key request for $outputPath$domain"
#Generate a key
# openssl genrsa -out host.key 2048
# openssl genrsa -des3 -out $domain.key 2048 -noout
openssl genrsa -passout pass:$password -out ./tmpCert/$domain.key 2048
# openssl genrsa -des3 -out $outputPath$domain.key 2048 -noout
openssl genrsa -passout pass:$password -out $outputPath$domain.key 2048
#Remove passphrase from the key. Comment the line out to keep the passphrase
echo "Removing passphrase from key"
openssl rsa -in ./tmpCert/$domain.key -passin pass:$password -out ./tmpCert/$domain.key
openssl rsa -in $outputPath$domain.key -passin pass:$password -out $outputPath$domain.key
#Create the request
echo "Creating CSR"
openssl req -new -key ./tmpCert/$domain.key -out ./tmpCert/$domain.csr -passin pass:$password \
openssl req -new -key $outputPath$domain.key -out $outputPath$domain.csr -passin pass:$password \
-subj "/C=$country/ST=$state/L=$locality/O=$organization/OU=$organizationalunit/CN=$commonname/emailAddress=$email"
#Generating a Self-Signed Certificate
openssl x509 -req -days 365 -in ./tmpCert/$domain.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out ./tmpCert/$domain.crt
#-signkey ./tmpCert/$domain.key
openssl x509 -req -days 365 -in $outputPath$domain.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out $outputPath$domain.crt
#-signkey $outputPath$domain.key
#openssl x509 -req -in host.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out host.crt -days 365
echo "Finished"

View File

@@ -1,4 +1,6 @@
#!/bin/bash
outputPath=$1
cd $outputPath
openssl genrsa -out rootCA.key 2048
openssl req -x509 -new -nodes -key rootCA.key -days 36500 -out rootCA.crt