Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support checking full chain #130

Open
rdoeffinger opened this issue Jul 25, 2023 · 0 comments
Open

Support checking full chain #130

rdoeffinger opened this issue Jul 25, 2023 · 0 comments

Comments

@rdoeffinger
Copy link

It currently cannot detect if some intermediate is expiring.
This could happen if the certificate chain was not updated for example.
Maybe this is a job for a different tool that checks validity more thoroughly like checkssl, but those don't have the email notification feature...
Just as a proof-of-concept, this truly horrible code below kind of works. As very minimum I expect it needs to have a command-line option to enable or disable, and it would be better if it could work with file inputs as well.

@@ -674,7 +674,7 @@
         OPTIONS="-connect ${1}:${2} -servername ${1} $TLSFLAG"
     fi
 
-    echo "" | "${OPENSSL}" s_client $OPTIONS 2> "${ERROR_TMP}" 1> "${CERT_TMP}"
+    echo "" | "${OPENSSL}" s_client $OPTIONS -showcerts 2> "${ERROR_TMP}" 1> "${CERT_TMP}"
 
     if "${GREP}" -i "Connection refused" "${ERROR_TMP}" > /dev/null; then
         prints "${1}" "${2}" "Connection refused" "Unknown"
@@ -699,6 +699,13 @@
         set_returncode 3
     else
         check_file_status "${CERT_TMP}" "${1}" "${2}"
+        next_cert_line=$(${GREP} -n "BEGIN CERTIFICATE" "${CERT_TMP}" | ${SED} -e 's/:.*//' | tail -n +2 | head -n 1)
+        while test -n "${next_cert_line}"; do
+            tail -n "+${next_cert_line}" "${CERT_TMP}" > "${ERROR_TMP}"
+            mv "${ERROR_TMP}" "${CERT_TMP}"
+            check_file_status "${CERT_TMP}" "${1}" "${2}"
+            next_cert_line=$(${GREP} -n "BEGIN CERTIFICATE" "${CERT_TMP}" | ${SED} -e 's/:.*//' | tail -n +2 | head -n 1)
+	done
     fi
 }
 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant