@@ -2658,7 +2658,7 @@ verify_retcode_helper() {
2658
2658
}
2659
2659
2660
2660
determine_trust () {
2661
- local heading =$1
2661
+ local json_prefix =$1
2662
2662
local -i i=1
2663
2663
local -i num_ca_bundles=0
2664
2664
local bundle_fname
@@ -2669,16 +2669,20 @@ determine_trust() {
2669
2669
local some_ok=false
2670
2670
local code
2671
2671
local ca_bundles=" $INSTALL_DIR /etc/*.pem"
2672
- local spaces=" "
2672
+ local spaces=" "
2673
2673
local -i certificates_provided=1+$( grep -c " \-\-\-\-\-BEGIN CERTIFICATE\-\-\-\-\-" $TEMPDIR /intermediatecerts.pem)
2674
2674
local addtl_warning
2675
+
2676
+ # If $json_prefix is not empty, then there is more than one certificate
2677
+ # and the output should should be indented by two more spaces.
2678
+ [[ -n $json_prefix ]] && spaces=" "
2675
2679
2676
2680
if [[ $OSSL_VER_MAJOR .$OSSL_VER_MINOR == " 1.1.0" ]]; then
2677
2681
addtl_warning=" (Your openssl 1.1.0 might be too new for a reliable check)"
2678
- fileout " $heading trust" " WARN" " Your $OPENSSL is too new, need version 1.0.2 to determine trust"
2682
+ fileout " ${json_prefix} trust" " WARN" " Your $OPENSSL is too new, need version 1.0.2 to determine trust"
2679
2683
elif [[ $OSSL_VER_MAJOR .$OSSL_VER_MINOR != " 1.0.2" ]]; then
2680
2684
addtl_warning=" (Your openssl <= 1.0.2 might be too unreliable to determine trust)"
2681
- fileout " $heading trust_warn" " WARN" " $addtl_warning "
2685
+ fileout " ${json_prefix} trust_warn" " WARN" " $addtl_warning "
2682
2686
fi
2683
2687
debugme outln
2684
2688
for bundle_fname in $ca_bundles ; do
@@ -2715,15 +2719,15 @@ determine_trust() {
2715
2719
if $all_ok ; then
2716
2720
# all stores ok
2717
2721
pr_litegreen " Ok " ; pr_litemagenta " $addtl_warning "
2718
- fileout " $heading trust" " OK" " All certificate trust checks passed. $addtl_warning "
2722
+ fileout " ${json_prefix} trust" " OK" " All certificate trust checks passed. $addtl_warning "
2719
2723
else
2720
2724
# at least one failed
2721
2725
pr_red " NOT ok"
2722
2726
if ! $some_ok ; then
2723
2727
# all failed (we assume with the same issue), we're displaying the reason
2724
2728
out " "
2725
2729
verify_retcode_helper " ${verify_retcode[2]} "
2726
- fileout " $heading trust" " NOT OK" " All certificate trust checks failed: $( verify_retcode_helper " ${verify_retcode[2]} " ) . $addtl_warning "
2730
+ fileout " ${json_prefix} trust" " NOT OK" " All certificate trust checks failed: $( verify_retcode_helper " ${verify_retcode[2]} " ) . $addtl_warning "
2727
2731
else
2728
2732
# is one ok and the others not ==> display the culprit store
2729
2733
if $some_ok ; then
@@ -2746,7 +2750,7 @@ determine_trust() {
2746
2750
[[ " $DEBUG " -eq 0 ]] && out " $spaces "
2747
2751
pr_litegreen " OK: $ok_was "
2748
2752
fi
2749
- fileout " $heading trust" " NOT OK" " Some certificate trust checks failed : OK : $ok_was NOT ok: $notok_was $addtl_warning "
2753
+ fileout " ${json_prefix} trust" " NOT OK" " Some certificate trust checks failed : OK : $ok_was NOT ok: $notok_was $addtl_warning "
2750
2754
fi
2751
2755
[[ -n " $addtl_warning " ]] && out " \n$spaces " && pr_litemagenta " $addtl_warning "
2752
2756
fi
@@ -2895,13 +2899,15 @@ certificate_info() {
2895
2899
local cnfinding
2896
2900
local cnok=" OK"
2897
2901
local expfinding expok=" OK"
2902
+ local json_prefix=" " # string to place at begging of JSON IDs when there is more than one certificate
2898
2903
local indent=" "
2899
2904
2900
2905
if [[ $number_of_certificates -gt 1 ]]; then
2901
2906
[[ $certificate_number -eq 1 ]] && outln
2902
2907
indent=" "
2903
2908
out " $indent "
2904
2909
pr_headlineln " Server Certificate #$certificate_number "
2910
+ json_prefix=" Server Certificate #$certificate_number "
2905
2911
spaces=" "
2906
2912
else
2907
2913
spaces=" "
@@ -2914,41 +2920,41 @@ certificate_info() {
2914
2920
case $sig_algo in
2915
2921
sha1WithRSAEncryption)
2916
2922
pr_brownln " SHA1 with RSA"
2917
- fileout " $heading algorithm" " WARN" " Signature Algorithm: SHA1 with RSA (warning)"
2923
+ fileout " ${json_prefix} algorithm" " WARN" " Signature Algorithm: SHA1 with RSA (warning)"
2918
2924
;;
2919
2925
sha256WithRSAEncryption)
2920
2926
pr_litegreenln " SHA256 with RSA"
2921
- fileout " $heading algorithm" " OK" " Signature Algorithm: SHA256 with RSA (OK)"
2927
+ fileout " ${json_prefix} algorithm" " OK" " Signature Algorithm: SHA256 with RSA (OK)"
2922
2928
;;
2923
2929
sha384WithRSAEncryption)
2924
2930
pr_litegreenln " SHA384 with RSA"
2925
- fileout " $heading algorithm" " OK" " Signature Algorithm: SHA384 with RSA (OK)"
2931
+ fileout " ${json_prefix} algorithm" " OK" " Signature Algorithm: SHA384 with RSA (OK)"
2926
2932
;;
2927
2933
sha512WithRSAEncryption)
2928
2934
pr_litegreenln " SHA512 with RSA"
2929
- fileout " $heading algorithm" " OK" " Signature Algorithm: SHA512 with RSA (OK)"
2935
+ fileout " ${json_prefix} algorithm" " OK" " Signature Algorithm: SHA512 with RSA (OK)"
2930
2936
;;
2931
2937
ecdsa-with-SHA256)
2932
2938
pr_litegreenln " ECDSA with SHA256"
2933
- fileout " $heading algorithm" " OK" " Signature Algorithm: ECDSA with SHA256 (OK)"
2939
+ fileout " ${json_prefix} algorithm" " OK" " Signature Algorithm: ECDSA with SHA256 (OK)"
2934
2940
;;
2935
2941
md5* )
2936
2942
pr_redln " MD5"
2937
- fileout " $heading algorithm" " NOT OK" " Signature Algorithm: MD5 (NOT ok)"
2943
+ fileout " ${json_prefix} algorithm" " NOT OK" " Signature Algorithm: MD5 (NOT ok)"
2938
2944
;;
2939
2945
* )
2940
2946
out " $sig_algo ("
2941
2947
pr_litemagenta " Unknown"
2942
2948
outln " )"
2943
- fileout " $heading algorithm" " INFO" " Signature Algorithm: $sign_algo "
2949
+ fileout " ${json_prefix} algorithm" " INFO" " Signature Algorithm: $sign_algo "
2944
2950
;;
2945
2951
esac
2946
2952
# old, but interesting: https://blog.hboeck.de/archives/754-Playing-with-the-EFF-SSL-Observatory.html
2947
2953
2948
2954
out " $indent " ; pr_bold " Server key size "
2949
2955
if [[ -z " $keysize " ]]; then
2950
2956
outln " (couldn't determine)"
2951
- fileout " $heading key_size" " WARN" " Server keys size cannot be determined"
2957
+ fileout " ${json_prefix} key_size" " WARN" " Server keys size cannot be determined"
2952
2958
else
2953
2959
# https://tools.ietf.org/html/rfc4492, http://www.keylength.com/en/compare/
2954
2960
# http://infoscience.epfl.ch/record/164526/files/NPDF-22.pdf
@@ -2957,53 +2963,53 @@ certificate_info() {
2957
2963
if [[ $sig_algo =~ ecdsa ]] || [[ $key_algo =~ ecPublicKey ]]; then
2958
2964
if [[ " $keysize " -le 110 ]]; then # a guess
2959
2965
pr_red " $keysize "
2960
- fileout " $heading key_size" " NOT OK" " Server keys $keysize EC bits (NOT ok)"
2966
+ fileout " ${json_prefix} key_size" " NOT OK" " Server keys $keysize EC bits (NOT ok)"
2961
2967
elif [[ " $keysize " -le 123 ]]; then # a guess
2962
2968
pr_litered " $keysize "
2963
- fileout " $heading key_size" " NOT OK" " Server keys $keysize EC bits (NOT ok)"
2969
+ fileout " ${json_prefix} key_size" " NOT OK" " Server keys $keysize EC bits (NOT ok)"
2964
2970
elif [[ " $keysize " -le 163 ]]; then
2965
2971
pr_brown " $keysize "
2966
- fileout " $heading key_size" " NOT OK" " Server keys $keysize EC bits (NOT ok)"
2972
+ fileout " ${json_prefix} key_size" " NOT OK" " Server keys $keysize EC bits (NOT ok)"
2967
2973
elif [[ " $keysize " -le 224 ]]; then
2968
2974
out " $keysize "
2969
- fileout " $heading key_size" " INFO" " Server keys $keysize EC bits"
2975
+ fileout " ${json_prefix} key_size" " INFO" " Server keys $keysize EC bits"
2970
2976
elif [[ " $keysize " -le 533 ]]; then
2971
2977
pr_litegreen " $keysize "
2972
- fileout " $heading key_size" " OK" " Server keys $keysize EC bits (OK)"
2978
+ fileout " ${json_prefix} key_size" " OK" " Server keys $keysize EC bits (OK)"
2973
2979
else
2974
2980
out " keysize: $keysize (not expected, FIXME)"
2975
- fileout " $heading key_size" " WARN" " Server keys $keysize bits (not expected)"
2981
+ fileout " ${json_prefix} key_size" " WARN" " Server keys $keysize bits (not expected)"
2976
2982
fi
2977
2983
outln " bit"
2978
2984
elif [[ $sig_algo = * RSA* ]]; then
2979
2985
if [[ " $keysize " -le 512 ]]; then
2980
2986
pr_red " $keysize "
2981
2987
outln " bits"
2982
- fileout " $heading key_size" " NOT OK" " Server keys $keysize bits (NOT ok)"
2988
+ fileout " ${json_prefix} key_size" " NOT OK" " Server keys $keysize bits (NOT ok)"
2983
2989
elif [[ " $keysize " -le 768 ]]; then
2984
2990
pr_litered " $keysize "
2985
2991
outln " bits"
2986
- fileout " $heading key_size" " NOT OK" " Server keys $keysize bits (NOT ok)"
2992
+ fileout " ${json_prefix} key_size" " NOT OK" " Server keys $keysize bits (NOT ok)"
2987
2993
elif [[ " $keysize " -le 1024 ]]; then
2988
2994
pr_brown " $keysize "
2989
2995
outln " bits"
2990
- fileout " $heading key_size" " NOT OK" " Server keys $keysize bits (NOT ok)"
2996
+ fileout " ${json_prefix} key_size" " NOT OK" " Server keys $keysize bits (NOT ok)"
2991
2997
elif [[ " $keysize " -le 2048 ]]; then
2992
2998
outln " $keysize bits"
2993
- fileout " $heading key_size" " INFO" " Server keys $keysize bits"
2999
+ fileout " ${json_prefix} key_size" " INFO" " Server keys $keysize bits"
2994
3000
elif [[ " $keysize " -le 4096 ]]; then
2995
3001
pr_litegreen " $keysize "
2996
- fileout " $heading key_size" " OK" " Server keys $keysize bits (OK)"
3002
+ fileout " ${json_prefix} key_size" " OK" " Server keys $keysize bits (OK)"
2997
3003
outln " bits"
2998
3004
else
2999
3005
pr_magenta " weird keysize: $keysize bits" ; outln " (could cause compatibility problems)"
3000
- fileout " $heading key_size" " WARN" " Server keys $keysize bits (Odd)"
3006
+ fileout " ${json_prefix} key_size" " WARN" " Server keys $keysize bits (Odd)"
3001
3007
fi
3002
3008
else
3003
3009
out " $keysize bits ("
3004
3010
pr_litemagenta " can't tell whether $keysize bits is good or not"
3005
3011
outln " )"
3006
- fileout " $heading key_size" " WARN" " Server keys $keysize bits (unknown signature algorithm)"
3012
+ fileout " ${json_prefix} key_size" " WARN" " Server keys $keysize bits (unknown signature algorithm)"
3007
3013
fi
3008
3014
fi
3009
3015
@@ -3013,7 +3019,7 @@ certificate_info() {
3013
3019
cert_fingerprint_sha2=" $( $OPENSSL x509 -noout -in $HOSTCERT -fingerprint -sha256 2>> $ERRFILE | sed ' s/Fingerprint=//' | sed ' s/://g' ) "
3014
3020
outln " $cert_fingerprint_sha1 / $cert_fingerprint_serial "
3015
3021
outln " $spaces$cert_fingerprint_sha2 "
3016
- fileout " $heading fingerprint" " INFO" " Fingerprints / Serial: $cert_fingerprint_sha1 / $cert_fingerprint_serial , $cert_fingerprint_sha2 "
3022
+ fileout " ${json_prefix} fingerprint" " INFO" " Fingerprints / Serial: $cert_fingerprint_sha1 / $cert_fingerprint_serial , $cert_fingerprint_sha2 "
3017
3023
3018
3024
out " $indent " ; pr_bold " Common Name (CN) "
3019
3025
cnfinding=" Common Name (CN) : "
@@ -3084,7 +3090,7 @@ certificate_info() {
3084
3090
cnfinding+=" (CN in response to request w/o SNI: \" $cn_nosni \" )"
3085
3091
fi
3086
3092
fi
3087
- fileout " $heading cn" " $cnok " " $cnfinding "
3093
+ fileout " ${json_prefix} cn" " $cnok " " $cnfinding "
3088
3094
3089
3095
sans=$( $OPENSSL x509 -in $HOSTCERT -noout -text 2>> $ERRFILE | grep -A3 " Subject Alternative Name" | grep " DNS:" | \
3090
3096
sed -e ' s/DNS://g' -e ' s/ //g' -e ' s/,/ /g' -e ' s/othername:<unsupported>//g' )
@@ -3095,10 +3101,10 @@ certificate_info() {
3095
3101
pr_dquoted " $san "
3096
3102
out " "
3097
3103
done
3098
- fileout " $heading san" " INFO" " subjectAltName (SAN) : $sans "
3104
+ fileout " ${json_prefix} san" " INFO" " subjectAltName (SAN) : $sans "
3099
3105
else
3100
3106
out " -- "
3101
- fileout " $heading san" " INFO" " subjectAltName (SAN) : --"
3107
+ fileout " ${json_prefix} san" " INFO" " subjectAltName (SAN) : --"
3102
3108
fi
3103
3109
outln
3104
3110
out " $indent " ; pr_bold " Issuer "
@@ -3110,17 +3116,17 @@ certificate_info() {
3110
3116
3111
3117
if [[ " $issuer_O " == " issuer=" ]] || [[ " $issuer_O " == " issuer= " ]] || [[ " $issuer_CN " == " $CN " ]]; then
3112
3118
pr_redln " self-signed (NOT ok)"
3113
- fileout " $heading issuer" " NOT OK" " Issuer: selfsigned (NOT ok)"
3119
+ fileout " ${json_prefix} issuer" " NOT OK" " Issuer: selfsigned (NOT ok)"
3114
3120
else
3115
3121
pr_dquoted " $issuer_CN "
3116
3122
out " ("
3117
3123
pr_dquoted " $issuer_O "
3118
3124
if [[ -n " $issuer_C " ]]; then
3119
3125
out " from "
3120
3126
pr_dquoted " $issuer_C "
3121
- fileout " $heading issuer" " INFO" " Issuer: \" $issuer \" ( \" $issuer_O \" from \" $issuer_C \" )"
3127
+ fileout " ${json_prefix} issuer" " INFO" " Issuer: \" $issuer \" ( \" $issuer_O \" from \" $issuer_C \" )"
3122
3128
else
3123
- fileout " $heading issuer" " INFO" " Issuer: \" $issuer \" ( \" $issuer_O \" )"
3129
+ fileout " ${json_prefix} issuer" " INFO" " Issuer: \" $issuer \" ( \" $issuer_O \" )"
3124
3130
fi
3125
3131
outln " )"
3126
3132
fi
@@ -3137,10 +3143,10 @@ certificate_info() {
3137
3143
[[ 1.3.6.1.4.1.17326.10.8.12.1.2 == " $policy_oid " ]] || \
3138
3144
[[ 1.3.6.1.4.1.13177.10.1.3.10 == " $policy_oid " ]] ; then
3139
3145
out " yes "
3140
- fileout " $heading ev" " OK" " Extended Validation (EV) (experimental) : yes"
3146
+ fileout " ${json_prefix} ev" " OK" " Extended Validation (EV) (experimental) : yes"
3141
3147
else
3142
3148
out " no "
3143
- fileout " $heading ev" " INFO" " Extended Validation (EV) (experimental) : no"
3149
+ fileout " ${json_prefix} ev" " INFO" " Extended Validation (EV) (experimental) : no"
3144
3150
fi
3145
3151
debugme echo " ($( newline_to_spaces " $policy_oid " ) )"
3146
3152
outln
@@ -3188,60 +3194,60 @@ certificate_info() {
3188
3194
fi
3189
3195
fi
3190
3196
outln " ($startdate --> $enddate )"
3191
- fileout " $heading expiration" " $expok " " Certificate Expiration : $expfinding ($startdate --> $enddate )"
3197
+ fileout " ${json_prefix} expiration" " $expok " " Certificate Expiration : $expfinding ($startdate --> $enddate )"
3192
3198
3193
3199
certificates_provided=1+$( grep -c " \-\-\-\-\-BEGIN CERTIFICATE\-\-\-\-\-" $TEMPDIR /intermediatecerts.pem)
3194
3200
out " $indent " ; pr_bold " # of certificates provided" ; outln " $certificates_provided "
3195
- fileout " $heading certcount" " INFO" " # of certificates provided : $certificates_provided "
3201
+ fileout " ${json_prefix} certcount" " INFO" " # of certificates provided : $certificates_provided "
3196
3202
3197
3203
3198
3204
out " $indent " ; pr_bold " Chain of trust" ; out " (experim.) "
3199
- determine_trust " $heading " # Also handles fileout
3205
+ determine_trust " $json_prefix " # Also handles fileout
3200
3206
3201
3207
out " $indent " ; pr_bold " Certificate Revocation List "
3202
3208
crl=" $( $OPENSSL x509 -in $HOSTCERT -noout -text 2>> $ERRFILE | grep -A 4 " CRL Distribution" | grep URI | sed ' s/^.*URI://' ) "
3203
3209
if [[ -z " $crl " ]]; then
3204
3210
pr_literedln " --"
3205
- fileout " $heading crl" " NOT OK" " No CRL provided (NOT ok)"
3211
+ fileout " ${json_prefix} crl" " NOT OK" " No CRL provided (NOT ok)"
3206
3212
elif grep -q http <<< " $crl" ; then
3207
3213
if [[ $( count_lines " $crl " ) -eq 1 ]]; then
3208
3214
outln " $crl "
3209
- fileout " $heading crl" " INFO" " Certificate Revocation List : $crl "
3215
+ fileout " ${json_prefix} crl" " INFO" " Certificate Revocation List : $crl "
3210
3216
else # more than one CRL
3211
3217
out_row_aligned " $crl " " $spaces "
3212
- fileout " $heading crl" " INFO" " Certificate Revocation List : $crl "
3218
+ fileout " ${json_prefix} crl" " INFO" " Certificate Revocation List : $crl "
3213
3219
fi
3214
3220
else
3215
3221
pr_litemagentaln " no parsable output \" $crl \" , pls report"
3216
- fileout " $heading crl" " WARN" " Certificate Revocation List : no parsable output \" $crl \" , pls report"
3222
+ fileout " ${json_prefix} crl" " WARN" " Certificate Revocation List : no parsable output \" $crl \" , pls report"
3217
3223
fi
3218
3224
3219
3225
out " $indent " ; pr_bold " OCSP URI "
3220
3226
ocsp_uri=$( $OPENSSL x509 -in $HOSTCERT -noout -ocsp_uri 2>> $ERRFILE )
3221
3227
if [[ -z " $ocsp_uri " ]]; then
3222
3228
pr_literedln " --"
3223
- fileout " $heading ocsp_uri" " NOT OK" " OCSP URI : -- (NOT ok)"
3229
+ fileout " ${json_prefix} ocsp_uri" " NOT OK" " OCSP URI : -- (NOT ok)"
3224
3230
else
3225
3231
outln " $ocsp_uri "
3226
- fileout " $heading ocsp_uri" " INFO" " OCSP URI : $ocsp_uri "
3232
+ fileout " ${json_prefix} ocsp_uri" " INFO" " OCSP URI : $ocsp_uri "
3227
3233
fi
3228
3234
3229
3235
out " $indent " ; pr_bold " OCSP stapling "
3230
3236
if grep -a " OCSP response" <<< " $ocsp_response" | grep -q " no response sent" ; then
3231
3237
pr_yellow " --"
3232
- fileout " $heading ocsp_stapling" " INFO" " OCSP stapling : not offered"
3238
+ fileout " ${json_prefix} ocsp_stapling" " INFO" " OCSP stapling : not offered"
3233
3239
else
3234
3240
if grep -a " OCSP Response Status" <<< " $ocsp_response_status" | grep -q successful; then
3235
3241
pr_litegreen " offered"
3236
- fileout " $heading ocsp_stapling" " OK" " OCSP stapling : offered"
3242
+ fileout " ${json_prefix} ocsp_stapling" " OK" " OCSP stapling : offered"
3237
3243
else
3238
3244
if $GOST_STATUS_PROBLEM ; then
3239
3245
outln " (GOST servers make problems here, sorry)"
3240
- fileout " $heading ocsp_stapling" " OK" " OCSP stapling : (GOST servers make problems here, sorry)"
3246
+ fileout " ${json_prefix} ocsp_stapling" " OK" " OCSP stapling : (GOST servers make problems here, sorry)"
3241
3247
ret=0
3242
3248
else
3243
3249
out " (response status unknown)"
3244
- fileout " $heading ocsp_stapling" " OK" " OCSP stapling : not sure what's going on here, debug: grep -aA 20 " OCSP response" <<<" $ocsp_response " "
3250
+ fileout " ${json_prefix} ocsp_stapling" " OK" " OCSP stapling : not sure what's going on here, debug: grep -aA 20 " OCSP response" <<<" $ocsp_response " "
3245
3251
debugme grep -a -A20 -B2 " OCSP response" <<< " $ocsp_response"
3246
3252
ret=2
3247
3253
fi
0 commit comments