Created
January 16, 2015 16:15
-
-
Save zimski/91adb44bc25c78bdc75c to your computer and use it in GitHub Desktop.
Generate trusted chain for NGINX/APACHE
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
#!/bin/sh | |
#ocsp_prepare web_site_name crt_file root_ca result_trusted_chain | |
touch $4 | |
cat $3 > $4 | |
DOMAIN=$1 | |
awk 'BEGIN {c=0;} /BEGIN CERT/{c++} { print > "cert." c ".pem"}' < $2 | |
for f in cert.*.pem | |
do | |
echo "Processing: $f" | |
ca_server=`openssl x509 -in $f -noout -text | grep $DOMAIN` | |
if [ -z "$ca_server" ] || [ $ca_server = " " ] || [ $ca_server = "" ] | |
then | |
echo "this certificate is not for $1, i will add it to $4" | |
cat $f >> $4 | |
else | |
echo "this certificate is for $1, it's excluded" | |
fi | |
done | |
rm cert.*.pem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment