Skip to content

Commit 01e6535

Browse files
authored
Merge pull request #2226 from dcooper16/fix_ct_30
Fix certificate_transparency()
2 parents 14ebd0f + d688845 commit 01e6535

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

testssl.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ DETECTED_TLS_VERSION="" # .. as hex string, e.g. 0300 or 0303
296296
TLS13_ONLY=false # Does the server support TLS 1.3 ONLY?
297297
OSSL_SHORTCUT=${OSSL_SHORTCUT:-false} # Hack: if during the scan turns out the OpenSSL binary supports TLS 1.3 would be a better choice, this enables it.
298298
TLS_EXTENSIONS=""
299+
CERTIFICATE_TRANSPARENCY_SOURCE=""
299300
declare -r NPN_PROTOs="spdy/4a2,spdy/3,spdy/3.1,spdy/2,spdy/1,http/1.1"
300301
# alpn_protos needs to be space-separated, not comma-seperated, including odd ones observed @ facebook and others, old ones like h2-17 omitted as they could not be found
301302
declare -r ALPN_PROTOs="h2 spdy/3.1 http/1.1 grpc-exp h2-fb spdy/1 spdy/2 spdy/3 stun.turn stun.nat-discovery webrtc c-webrtc ftp"
@@ -8118,16 +8119,18 @@ certificate_transparency() {
81188119
# Cipher suites that use a certificate with a GOST public key
81198120
local -r a_gost="00,80, 00,81, 00,82, 00,83"
81208121

8122+
CERTIFICATE_TRANSPARENCY_SOURCE=""
8123+
81218124
# First check whether signed certificate timestamps (SCT) are included in the
81228125
# server's certificate. If they aren't, check whether the server provided
81238126
# a stapled OCSP response with SCTs. If no SCTs were found in the certificate
81248127
# or OCSP response, check for an SCT TLS extension.
81258128
if [[ "$cert_txt" =~ CT\ Precertificate\ SCTs ]] || [[ "$cert_txt" =~ '1.3.6.1.4.1.11129.2.4.2' ]]; then
8126-
tm_out "certificate extension"
8129+
CERTIFICATE_TRANSPARENCY_SOURCE="certificate extension"
81278130
return 0
81288131
fi
81298132
if [[ "$ocsp_response" =~ CT\ Certificate\ SCTs ]] || [[ "$ocsp_response" =~ '1.3.6.1.4.1.11129.2.4.5' ]]; then
8130-
tm_out "OCSP extension"
8133+
CERTIFICATE_TRANSPARENCY_SOURCE="OCSP extension"
81318134
return 0
81328135
fi
81338136

@@ -8136,7 +8139,7 @@ certificate_transparency() {
81368139
# one certificate, then it is possible that an SCT TLS extension is returned for some
81378140
# certificates, but not for all of them.
81388141
if [[ $number_of_certificates -eq 1 ]] && [[ "$TLS_EXTENSIONS" =~ signed\ certificate\ timestamps ]]; then
8139-
tm_out "TLS extension"
8142+
CERTIFICATE_TRANSPARENCY_SOURCE="TLS extension"
81408143
return 0
81418144
fi
81428145

@@ -8169,16 +8172,16 @@ certificate_transparency() {
81698172
if ( [[ $success -eq 0 ]] || [[ $success -eq 2 ]] ) && \
81708173
grep -a 'TLS server extension ' "$TEMPDIR/$NODEIP.parse_tls_serverhello.txt" | \
81718174
grep -aq "signed certificate timestamps"; then
8172-
tm_out "TLS extension"
8175+
CERTIFICATE_TRANSPARENCY_SOURCE="TLS extension"
81738176
return 0
81748177
fi
81758178
fi
81768179

81778180
if [[ $SERVICE != HTTP ]] && ! "$CLIENT_AUTH"; then
81788181
# At the moment Certificate Transparency only applies to HTTPS.
8179-
tm_out "N/A"
8182+
CERTIFICATE_TRANSPARENCY_SOURCE="N/A"
81808183
else
8181-
tm_out "--"
8184+
CERTIFICATE_TRANSPARENCY_SOURCE="--"
81828185
fi
81838186
return 0
81848187
}
@@ -9366,7 +9369,8 @@ run_server_defaults() {
93669369
# Now that all of the server's certificates have been found, determine for
93679370
# each certificate whether certificate transparency information is provided.
93689371
for (( i=1; i <= certs_found; i++ )); do
9369-
ct[i]="$(certificate_transparency "${previous_hostcert_txt[i]}" "${ocsp_response[i]}" "$certs_found" "${cipher[i]}" "${sni_used[i]}" "${tls_version[i]}")"
9372+
certificate_transparency "${previous_hostcert_txt[i]}" "${ocsp_response[i]}" "$certs_found" "${cipher[i]}" "${sni_used[i]}" "${tls_version[i]}"
9373+
ct[i]="$CERTIFICATE_TRANSPARENCY_SOURCE"
93709374
# If certificate_transparency() called tls_sockets() and found a "signed certificate timestamps" extension,
93719375
# then add it to $TLS_EXTENSIONS, since it may not have been found by determine_tls_extensions().
93729376
[[ $certs_found -gt 1 ]] && [[ "${ct[i]}" == TLS\ extension ]] && extract_new_tls_extensions "$TEMPDIR/$NODEIP.parse_tls_serverhello.txt"
@@ -20191,6 +20195,7 @@ nodeip_to_proper_ip6() {
2019120195

2019220196
reset_hostdepended_vars() {
2019320197
TLS_EXTENSIONS=""
20198+
CERTIFICATE_TRANSPARENCY_SOURCE=""
2019420199
PROTOS_OFFERED=""
2019520200
CURVES_OFFERED=""
2019620201
OPTIMAL_PROTO=""

0 commit comments

Comments
 (0)