matteocorti / check_ssl_cert

A shell script (that can be used as a Nagios/Icinga plugin) to check an SSL/TLS connection.
GNU General Public License v3.0
368 stars 132 forks source link

AIX compatibility #306

Closed szcsdev closed 2 years ago

szcsdev commented 3 years ago

Is your feature request related to a problem? Please describe. It can't be used on AIX 7.2, because some switch from sed, grep isn't working on AIX

Describe the solution you'd like I downloaded the latest version 2.4.0, but didn't worked. I tried an older version 2.3.7 that's seem to be work, but i had some error messages. First, i had problem, with the create temporary file function. AIX 7.2 doesn't have mktemp command, i found a solution on the internet to resolve this problem i changed this row TEMPFILE="$( mktemp "${TMPDIR}/XXXXXX" 2> /dev/null ) to this TEMPFILE="XXX-$(od -N4 -tu /tmp | awk 'NR==1 {print $2} {}')" - it works perfectly. Twice i get the following error: unknown 'temporary file creation failure.' - i put the if section in twice, then i have problem with the [ ! -w "${TEMPFILE}" ] check - i don't understand what it does. - check the temp file is writable? I commented out, and the scipts seems to be working, but i get some error messages. sed: illegal option -- E /usr/bin/file: illegal option -- L grep: illegal option -- m grep: illegal option -- A /usr/bin/date: illegal option -- j

so i see that the script can resolve the until date, but the from date no, and the remaining days are wrong too debug_log.txt

Describe alternatives you've considered

Additional context

matteocorti commented 3 years ago

Hi I'll try to take a look but without am AIX System to test and debug it will be difficult. Matteo

matteocorti commented 3 years ago

http://www.polarhome.com/ could be worth a look.

matteocorti commented 3 years ago

It would be nice to have it running on AIX but I should need a way to be able to test. Still trying to find an AIX system :-)

matteocorti commented 3 years ago

https://worthdoingbadly.com/aixqemu/

matteocorti commented 3 years ago

https://worthdoingbadly.com/aixqemu/

Not really working

matteocorti commented 3 years ago

It seems that there are a lot of incompatibilities. Without an AIX system I cannot do much. Feel free to submit a patch. If you can provide me with a shell account on an AIX system I could try to take a look.

I'll leave the issue open in case someone is willing to help.

matteocorti commented 2 years ago

I committed a version which does not use mktemp

matteocorti commented 2 years ago

Next issue: sed -E:

536:    OPENSSL_VERSION=$(echo "${OPENSSL_VERSION}" | sed -E 's/^(Libre|Open)SSL\ ([^ \-]*).*/\2/')
3394:        OPENSSL_DIR="$(${OPENSSL} version -d | sed -E 's/OPENSSLDIR: "([^"]*)"/\1/')"
4022:    ISSUERS=$(echo "${ISSUERS}" | sed 's/\\n/\n/g' | sed -E -e 's/^issuer=( \/)?//' | awk '{gsub(", ","\n")};1' | grep -E "^(O|CN) ?= ?")
4292:        CA_ISSUER_MATCHED=$(echo "${ISSUERS}" | grep -E "^(O|CN) ?= ?${ISSUER}\$" | sed -E -e "s/^(O|CN) ?= ?//" | head -n1)
4300:            prepend_critical_message "invalid CA ('$(echo "${ISSUER}" | sed "s/|/ PIPE /g")' does not match '$(echo "${ISSUERS}" | sed -E -e "s/^(O|CN) ?= ?//" | tr '\n' '|' | sed 's/|$//g' | sed "s/|/\\' or \\'/g")')"
4311:        debuglog "  executing echo \"${ISSUERS}\" | sed -E -e \"s/^(O|CN) ?= ?//\" | grep -E \"^${NOT_ISSUED_BY}\$\" | head -n1"
4314:        CA_ISSUER_MATCHED=$(echo "${ISSUERS}" | sed -E -e "s/^(O|CN) ?= ?//" | grep -E "^${NOT_ISSUED_BY}\$" | head -n1)
4320:            prepend_critical_message "invalid CA ('$(echo "${NOT_ISSUED_BY}" | sed "s/|/ PIPE /g")' matches '$(echo "${ISSUERS}" | sed -E -e "s/^(O|CN) ?= ?//" | tr '\n' '|' | sed 's/|$//g' | sed "s/|/\\' or \\'/g")')"
4323:            CA_ISSUER_MATCHED="$(echo "${ISSUERS}" | grep -E "^CN ?= ?" | sed -E -e "s/^CN ?= ?//" | head -n1)"
4328:        CA_ISSUER_MATCHED="$(echo "${ISSUERS}" | grep -E "^CN ?= ?" | sed -E -e "s/^CN ?= ?//" | head -n1)"
matteocorti commented 2 years ago

I give up. Even file -L is not there... If someone is interested feel free to update the script

szcsdev commented 2 years ago

Hi!

I tried to simplify the situation and got to the point where I read the dates out and got the number of days left. I would ask for your help on how I can turn on alerts in my code. If you have any idea how to simplify the attached code, thank you too. check_ssl_cert_aix.txt

matteocorti commented 2 years ago

Hi

It' really difficult for me to implement a patch blindly. As long as I don't have access to an AIX account, it will be impossible to do something. I checked where I work and some other institutions but we decommissioned the last AIX machines years ago.

szcsdev commented 2 years ago

as you seen the code i get the remaining daysout without tempfile, and any sed or something, but i don't understand how can i simply put to nagios screen.

matteocorti commented 2 years ago

Sorry I cannot help. I will not develop blindly. Either someone helps with an account where I can test or someone submits a complete and working patch that does not break any test.

I develop for free and distribute my code for free. I cannot do miracles and develop for a system I don't have access to.

szcsdev commented 2 years ago

Ok, i understand. thank you