From e0c1e9d7cff9ad523b927b3d552f0dc262c9d37b Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Wed, 2 Mar 2016 18:48:22 +0200
Subject: [PATCH] Rename find_cert_by_hash to find_cert_by_issuer_hash, sync
 docs.

---
 README.rst   |  5 +++--
 bundle_certs | 11 ++++++-----
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/README.rst b/README.rst
index 024b057..a30747c 100644
--- a/README.rst
+++ b/README.rst
@@ -47,8 +47,9 @@ Shell functions
 - issuer_hash: Returns OpenSSL's hash of the cert's issuer.
 - find_root_cert: Return the filename of the (first) root (self-signed)
   certificate of the filenames passed as parameters.
-- find_cert_by_hash: Gets a hash and a list of filenames, returns the
-  filename of the certificate with that subject hash.
+- find_cert_by_issuer_hash: Gets a hash and a list of filenames, returns the
+  filename of the certificate with that issuer hash. Ignores self-signed (root
+  CA) certificates.
 - unbudle_cert: Gets a filename, creates a directory named :code:`certs` which
   contains all of the individual certs in the file (the files are named by their
   subject hash).
diff --git a/bundle_certs b/bundle_certs
index 948c91c..2f79e3f 100755
--- a/bundle_certs
+++ b/bundle_certs
@@ -23,9 +23,10 @@ find_root_cert () {
     done
 }
 
-find_cert_by_hash () {
-    # Recieves the issuer hash and a list of file paths, returns the path to
-    # the certificate which was issued by that hash.
+find_cert_by_issuer_hash () {
+    # Gets a hash and a list of filenames, returns the
+    # filename of the certificate with that issuer hash. Ignores self-signed
+    # (root CA) certificates.
     certhash="$1"
     shift
     for filename in "$@"
@@ -66,12 +67,12 @@ bundle_certs () {
         echo "Failed to find root certificate." > /dev/stderr
         exit 1
     fi
-    issued="$(find_cert_by_hash $issuer *)"
+    issued="$(find_cert_by_issuer_hash $issuer *)"
     while [ -n "$issued" ]
     do
         ordered_certs="$issued $ordered_certs"
         issuer="$issued"
-        issued="$(find_cert_by_hash $issuer *)"
+        issued="$(find_cert_by_issuer_hash $issuer *)"
     done
     cat $ordered_certs
     cd ..
-- 
GitLab