Skip to content

Commit 5581499

Browse files
authored
Merge pull request #2487 from Tazmaniac/renego-fix3
[Client Renego] Small important fixes
2 parents 979a22c + 6d80ec1 commit 5581499

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

testssl.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17060,6 +17060,8 @@ run_renego() {
1706017060
# We will need $ERRFILE for mitigation detection
1706117061
if [[ $ERRFILE =~ dev.null ]]; then
1706217062
ERRFILE=$TEMPDIR/errorfile.txt || exit $ERR_FCREATE
17063+
# cleanup previous run if any (multiple IP)
17064+
rm -f $ERRFILE
1706317065
restore_errfile=1
1706417066
else
1706517067
restore_errfile=0
@@ -17105,21 +17107,27 @@ run_renego() {
1710517107
(j=0; while [[ $(grep -ac '^SSL-Session:' $TMPFILE) -ne 1 ]] && [[ $j -lt 30 ]]; do sleep $ssl_reneg_wait; ((j++)); done; \
1710617108
for ((i=0; i < ssl_reneg_attempts; i++ )); do sleep $ssl_reneg_wait; echo R; k=0; \
1710717109
while [[ $(grep -ac '^RENEGOTIATING' $ERRFILE) -ne $((i+3)) ]] && [[ -f $TEMPDIR/allowed_to_loop ]] \
17108-
&& [[ $(tail -n1 $ERRFILE |grep -acE '^(RENEGOTIATING|depth|verify)') -eq 1 ]] && [[ $k -lt 120 ]]; \
17109-
do sleep $ssl_reneg_wait; ((k++)); done; \
17110+
&& [[ $(tail -n1 $ERRFILE |grep -acE '^(RENEGOTIATING|depth|verify|notAfter)') -eq 1 ]] \
17111+
&& [[ $k -lt 120 ]]; \
17112+
do sleep $ssl_reneg_wait; ((k++)); if (tail -5 $TMPFILE| grep -qa '^closed'); then sleep 1; break; fi; done; \
1711017113
done) | \
1711117114
$OPENSSL s_client $(s_client_options "$proto $legacycmd $STARTTLS $BUGS -connect $NODEIP:$PORT $PROXY $SNI") >$TMPFILE 2>>$ERRFILE &
1711217115
pid=$!
1711317116
( sleep $((ssl_reneg_attempts*3)) && kill $pid && touch $TEMPDIR/was_killed ) >&2 2>/dev/null &
1711417117
watcher=$!
17115-
# Trick to get the return value of the openssl command, output redirection and a timeout. Yes, some target hang/block after some tries.
17118+
# Trick to get the return value of the openssl command, output redirection and a timeout.
17119+
# Yes, some target hang/block after some tries.
1711617120
wait $pid
1711717121
tmp_result=$?
1711817122
pkill -HUP -P $watcher
1711917123
wait $watcher
1712017124
rm -f $TEMPDIR/allowed_to_loop
1712117125
# If we are here, we have done two successful renegotiation (-2) and do the loop
1712217126
loop_reneg=$(($(grep -ac '^RENEGOTIATING' $ERRFILE)-2))
17127+
# As above, some servers close the connection and return value is zero
17128+
if (tail -5 $TMPFILE| grep -qa '^closed'); then
17129+
tmp_result=1
17130+
fi
1712317131
if [[ -f $TEMPDIR/was_killed ]]; then
1712417132
tmp_result=2
1712517133
rm -f $TEMPDIR/was_killed

0 commit comments

Comments
 (0)