Skip to content
Snippets Groups Projects
Commit deaac291 authored by nimrod's avatar nimrod
Browse files

- Declare local variables.

parent 32249739
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,7 @@ alias issuer_hash='openssl x509 -noout -issuer_hash -in' ...@@ -12,6 +12,7 @@ alias issuer_hash='openssl x509 -noout -issuer_hash -in'
find_root_cert () { find_root_cert () {
# Returns the (first) root (self-signed) certificate found in the list # Returns the (first) root (self-signed) certificate found in the list
# of file paths provided. # of file paths provided.
local filename
for filename in "$@" for filename in "$@"
do do
if [ -f "$filename" ] && \ if [ -f "$filename" ] && \
...@@ -27,6 +28,7 @@ find_cert_by_issuer_hash () { ...@@ -27,6 +28,7 @@ find_cert_by_issuer_hash () {
# Gets a hash and a list of filenames, returns the # Gets a hash and a list of filenames, returns the
# filename of the certificate with that issuer hash. Ignores self-signed # filename of the certificate with that issuer hash. Ignores self-signed
# (root CA) certificates. # (root CA) certificates.
local certhash filename
certhash="$1" certhash="$1"
shift shift
for filename in "$@" for filename in "$@"
...@@ -45,6 +47,7 @@ unbundle_cert () { ...@@ -45,6 +47,7 @@ unbundle_cert () {
# Recieves a file path, creates a directory named certs with all of the # Recieves a file path, creates a directory named certs with all of the
# individual certs contained within that file inside the directory (the # individual certs contained within that file inside the directory (the
# filenames are the subject hash for each certificate). # filenames are the subject hash for each certificate).
local certificate
mkdir -p certs mkdir -p certs
awk '/-----BEGIN[A-Z0-9 ]*CERTIFICATE-----/ {n++} \ awk '/-----BEGIN[A-Z0-9 ]*CERTIFICATE-----/ {n++} \
n > 0 {print > "certs/cert" (1+n)}' "$1" n > 0 {print > "certs/cert" (1+n)}' "$1"
...@@ -56,6 +59,7 @@ unbundle_cert () { ...@@ -56,6 +59,7 @@ unbundle_cert () {
} }
bundle_certs () { bundle_certs () {
local issuer issued ordered_certs filename
for filename in "$@" for filename in "$@"
do do
[ -f "$filename" ] && unbundle_cert "$filename" [ -f "$filename" ] && unbundle_cert "$filename"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment