@@ -18317,26 +18317,30 @@ check_proxy() {
1831718317}
1831818318
1831918319
18320- # this is only being called from determine_optimal_proto in order to check whether we have a server
18321- # with client authentication, a server with no SSL session ID switched off
18320+ # This is only being called from determine_optimal_proto() in order to check whether we have a server with
18321+ # client authentication, a server with no SSL session ID switched off -- and as the name indicates a protocol.
18322+ # ARG1 is the return value of openssl s_client connect. (Darwin or LibreSSL may return 1 here)
18323+ # ARG2 is the file name containing the server hello
1832218324#
1832318325sclient_auth() {
18324- [[ $1 -eq 0 ]] && return 0 # no client auth (CLIENT_AUTH=false is preset globally)
18325- if [[ -n $(awk '/Master-Key: / { print $2 }' "$2") ]]; then # connect succeeded
18326- if grep -q '^<<< .*CertificateRequest' "$2"; then # CertificateRequest message in -msg
18327- CLIENT_AUTH=true
18328- return 0
18329- fi
18330- if [[ -z $(awk '/Session-ID: / { print $2 }' "$2") ]]; then # probably no SSL session
18331- if [[ 2 -eq $(grep -c CERTIFICATE "$2") ]]; then # do another sanity check to be sure
18326+ local -i ret=1
18327+
18328+ if [[ $1 -eq 0 ]] ; then
18329+ ret=0 # no client auth (CLIENT_AUTH=false is preset globally)
18330+ else
18331+ if [[ -n $(awk '/Master-Key: / { print $2 }' "$2") ]]; then # connect succeeded
18332+ if grep -q '^<<< .*CertificateRequest' "$2"; then # CertificateRequest message in -msg
18333+ CLIENT_AUTH=true
18334+ ret=0
18335+ elif [[ 2 -eq $(grep -c CERTIFICATE "$2") ]]; then # do another sanity check to be sure
1833218336 CLIENT_AUTH=false
18333- NO_SSL_SESSIONID=true # NO_SSL_SESSIONID is preset globally to false for all other cases
18334- return 0
18337+ ret=0
1833518338 fi
1833618339 fi
1833718340 fi
18338- # what's left now is: master key empty, handshake returned not successful, session ID empty --> not successful
18339- return 1
18341+ [[ $ret -eq 0 ]] && \
18342+ [[ -z $(awk '/Session-ID: / { print $2 }' "$2") ]] && NO_SSL_SESSIONID=true # NO_SSL_SESSIONID is preset globally first
18343+ return $ret
1834018344}
1834118345
1834218346# Determine the best parameters to use with tls_sockets():
0 commit comments