@@ -8317,6 +8317,13 @@ certificate_transparency() {
83178317 return 0
83188318}
83198319
8320+ determine_certs_fingerprints_serial() {
8321+ local cert="$1"
8322+ local ossl_command="$2"
8323+
8324+ }
8325+
8326+
83208327certificate_info() {
83218328 local proto
83228329 local -i certificate_number=$1
@@ -8341,7 +8348,7 @@ certificate_info() {
83418348 local startdate enddate issuer_CN issuer_C issuer_O issuer sans san all_san="" cn
83428349 local issuer_DC issuerfinding cn_nosni=""
83438350 local cert_fingerprint_sha1 cert_fingerprint_sha2 cert_serial cert
8344- local -a intermediate_certs =()
8351+ local -a intermediate_certs_txt =()
83458352 local policy_oid
83468353 local spaces=""
83478354 local -i trust_sni=0 trust_nosni=0 diffseconds=0
@@ -8364,7 +8371,7 @@ certificate_info() {
83648371 local yearstart yearend clockstart clockend y m d
83658372 local gt_398=false gt_398warn=false
83668373 local gt_825=false gt_825warn=false
8367- local badocsp=1
8374+ local badocsp=1
83688375
83698376 if [[ $number_of_certificates -gt 1 ]]; then
83708377 [[ $certificate_number -eq 1 ]] && outln
@@ -8700,14 +8707,19 @@ certificate_info() {
87008707 fi
87018708
87028709 out "$indent"; pr_bold " Serial / Fingerprints "
8703- cert_serial="$($OPENSSL x509 -noout -in $HOSTCERT -serial 2>>$ERRFILE | sed 's/serial=//')"
8710+ cert_serial="$($OPENSSL x509 -noout -in $HOSTCERT -serial 2>>$ERRFILE)"
8711+ cert_serial="${cert_serial//serial=}"
87048712 fileout "cert_serialNumber${json_postfix}" "INFO" "$cert_serial"
87058713
8706- cert_fingerprint_sha1="$($OPENSSL x509 -noout -in $HOSTCERT -fingerprint -sha1 2>>$ERRFILE | sed 's/Fingerprint=//' | sed 's/://g')"
8707- fileout "cert_fingerprintSHA1${json_postfix}" "INFO" "${cert_fingerprint_sha1//SHA1 /}"
8714+ cert_fingerprint_sha1="$($OPENSSL x509 -noout -in $HOSTCERT -fingerprint -sha1 2>>$ERRFILE)"
8715+ cert_fingerprint_sha1="${cert_fingerprint_sha1//Fingerprint=}"
8716+ cert_fingerprint_sha1="${cert_fingerprint_sha1//:/}"
87088717 outln "$cert_serial / $cert_fingerprint_sha1"
8718+ fileout "cert_fingerprintSHA1${json_postfix}" "INFO" "${cert_fingerprint_sha1//SHA1 /}"
87098719
8710- cert_fingerprint_sha2="$($OPENSSL x509 -noout -in $HOSTCERT -fingerprint -sha256 2>>$ERRFILE | sed 's/Fingerprint=//' | sed 's/://g' )"
8720+ cert_fingerprint_sha2="$($OPENSSL x509 -noout -in $HOSTCERT -fingerprint -sha256 2>>$ERRFILE)"
8721+ cert_fingerprint_sha2="${cert_fingerprint_sha2//Fingerprint=}"
8722+ cert_fingerprint_sha2="${cert_fingerprint_sha2//:/}"
87118723 fileout "cert_fingerprintSHA256${json_postfix}" "INFO" "${cert_fingerprint_sha2//SHA256 /}"
87128724 outln "$spaces$cert_fingerprint_sha2"
87138725
@@ -8988,35 +9000,38 @@ certificate_info() {
89889000# https://certs.opera.com/03/ev-oids.xml
89899001# see #967
89909002
8991- # courtesy Hanno Boeck (see https://github.com/hannob/badocspcert)
8992- out "$indent"; pr_bold " Bad OCSP intermediate"
8993- out " (exp.) "
8994- jsonID="cert_bad_ocsp"
89959003
89969004# There might be >1 certificate, so we split intermediatecerts.pem e.g. into
89979005# intermediatecert1.crt, intermediatecert2.cert.
8998- #FIXME: This is redundant code. We do that elsewhere, e.g. before in extract_certificates()
8999- # and run_hpkp() at least but didn't keep the result
9000- #
9001- #FIXME: We just raise the flag saying the chain is bad w/o naming the intermediate
9002- # cert to blame.
9006+ #FIXME: This is somewhat redundant code. We do similar stuff elsewhere, e.g. in extract_certificates()
9007+ # and run_hpkp() but don't keep the result
90039008
9004- # Store all of the intermediate certificates in an array so that they can
9009+ # Store all of the text output of the intermediate certificates in an array so that they can
90059010 # be used later (e.g., to check their expiration dates).
90069011 while true; do
90079012 [[ "$intermediates" =~ \-\-\-\-\-\BEGIN\ CERTIFICATE\-\-\-\-\- ]] || break
90089013 intermediates="${intermediates#*-----BEGIN CERTIFICATE-----}"
90099014 cert="${intermediates%%-----END CERTIFICATE-----*}"
90109015 intermediates="${intermediates#${cert}-----END CERTIFICATE-----}"
90119016 cert="-----BEGIN CERTIFICATE-----${cert}-----END CERTIFICATE-----"
9012- intermediate_certs[certificates_provided]="$($OPENSSL x509 -text -noout 2>/dev/null <<< "$cert")"
9017+ # we count as humans in the file output here. This needs later to be adjusted in the code
9018+ fileout "intermediate_cert $((certificates_provided + 1 ))" "INFO" "$cert"
9019+ intermediate_certs_txt[certificates_provided]="$($OPENSSL x509 -text -noout 2>/dev/null <<< "$cert")"
90139020 certificates_provided+=1
90149021 done
9022+
9023+ # courtesy Hanno Boeck (see https://github.com/hannob/badocspcert)
9024+ out "$indent"; pr_bold " Bad OCSP intermediate"
9025+ out " (exp.) "
9026+ jsonID="cert_bad_ocsp"
9027+
90159028 certificates_provided+=1
90169029 for (( i=0; i < certificates_provided-1; i++ )); do
9017- cert_ext_keyusage="$(awk '/X509v3 Extended Key Usage:/ { getline; print $0 }' <<< "${intermediate_certs [i]}")"
9030+ cert_ext_keyusage="$(awk '/X509v3 Extended Key Usage:/ { getline; print $0 }' <<< "${intermediate_certs_txt [i]}")"
90189031 [[ "$cert_ext_keyusage" =~ OCSP\ Signing ]] && badocsp=0 && break
90199032 done
9033+
9034+ #FIXME: We only raise the flag saying the chain is bad w/o naming the intermediate cert to blame.
90209035 if [[ $badocsp -eq 0 ]]; then
90219036 prln_svrty_medium "NOT ok"
90229037 fileout "${jsonID}${json_postfix}" "MEDIUM" "NOT ok is/are intermediate certificate(s)"
0 commit comments