#!/bin/sh
# ConvertScript.sh
#
# This script is designed to take a p7b certificate bundle and convert it to a cer certificate bundle
#
# Created by David Kittell on 8/8/16.
#
clear
# Variables - Start
declare sCerCert=""
# Variables - Stop
echo "Current Directory: $(pwd)\n"
# Ask user for the directory that the p7b cert is in
printf "What directory is the p7b cert in?\n"
read sCertDirectory
# Evaluate the given directory
eval dir="$sCertDirectory"
sCertDirectory=$(echo $dir | sed "s,/$,,")
echo "\nCert Location: $sCertDirectory\n"
# Loop through the given directory and convert each p7b file
echo "NOTE: Conversion does not remove the P7B file"
for filename in $sCertDirectory/*.p7b; do
#echo "$filename\n"
sCerCert=${filename%.p7b}.cer
echo "Converting $filename to $sCerCert"
openssl pkcs7 -inform DER -outform PEM -in $filename -print_certs > $sCerCert
done
Originally Posted on August 8, 2016
Last Updated on April 2, 2018
Last Updated on April 2, 2018
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.