forked from gavinandresen/paymentrequest
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Script to create chain of intermediate CAs
- Loading branch information
1 parent
a0319ea
commit b916ac8
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Create 8 intermediate certificate authorities, each dependent on the previous | ||
# | ||
# Run create_ca.sh first to generate the root certificate authority. | ||
# | ||
|
||
set -x | ||
|
||
parent=$(pwd) | ||
|
||
for i in {1..8}; do | ||
mkdir -p intermediate_${i} | ||
pushd intermediate_${i} | ||
child=$(pwd) | ||
sed "s/Test CA/Intermediate CA ${i}/" < ../openssl.cnf > openssl.cnf | ||
|
||
if [ ! -f serial ]; then echo '01' > serial; fi | ||
touch index.txt | ||
touch index.txt.attr | ||
|
||
mkdir -p private && chmod go-rw private | ||
mkdir -p certs | ||
|
||
openssl genpkey -pass pass: -algorithm RSA -out private/cakey.pem -outform PEM | ||
openssl req -new -batch -subj "/CN=testca${i}.org/O=Payment Request Intermediate ${i}/" -sha1 -key private/cakey.pem -out ${parent}/ca${i}.csr | ||
popd | ||
|
||
# Get parent to sign: | ||
pushd ${parent} | ||
openssl ca -config openssl.cnf -batch -in ca${i}.csr -cert certs/cacert.pem -keyfile private/cakey.pem -notext -out certs/cacert${i}.pem | ||
cp certs/cacert${i}.pem ${child}/certs/cacert.pem | ||
popd | ||
|
||
# Create a merchant cert: | ||
pushd intermediate_${i} | ||
openssl genpkey -pass pass: -algorithm RSA -out private/demomerchantkey.pem -outform PEM | ||
openssl req -new -batch -subj "/CN=testmerchant${i}.org/O=Test Merchant ${i}/" -days 3600 -key private/demomerchantkey.pem -out /tmp/demomerchant.csr -outform PEM | ||
openssl ca -config openssl.cnf -batch -in /tmp/demomerchant.csr -cert certs/cacert.pem -keyfile private/cakey.pem -notext -out certs/demomerchant.pem | ||
rm /tmp/demomerchant.csr | ||
popd | ||
|
||
parent=$(pwd)/intermediate_${i} | ||
done | ||
|