Last active
July 7, 2021 15:02
-
-
Save crotel/521a3f48fbd082a620f00b5b412aa658 to your computer and use it in GitHub Desktop.
A ssl cert and key verify shell
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/bash | |
# createAt 20210701 | |
# Author: CROTEL | |
# | |
# Usage: | |
# | |
# ./sslverify.sh cert=/etc/nginx/ssl/server.crt key=/etc/nginx/ssl/server.key | |
# | |
# crt and key must use absolutely location | |
# | |
# updateAt 20210707 | |
# add DNS, Subject, Issuer[s] and OCSP. | |
for ARGUMENT in "$@" | |
do | |
KEY=$(echo $ARGUMENT | cut -f1 -d=) | |
VALUE=$(echo $ARGUMENT | cut -f2 -d=) | |
case "$KEY" in | |
cert) CERTPATH=${VALUE} ;; | |
key) KEYPATH=${VALUE} ;; | |
*) | |
esac | |
done | |
function expir() | |
{ | |
openssl x509 -text -noout -in $CERTPATH | grep -e 'Before\|After\|DNS\|Subject:\|Issuer[:s]\|OCSP' | |
} | |
function certmd5() | |
{ | |
openssl x509 -noout -modulus -in $CERTPATH | openssl md5 | |
} | |
function keymd5() | |
{ | |
openssl rsa -noout -modulus -in $KEYPATH | openssl md5 | |
} | |
echo "$(expir)" | |
if [[ "$certmd5" -eq "$keymd5" ]] | |
then | |
echo "Verified: OK" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment