Skip to content

Commit 35fc382

Browse files
author
Erlang/OTP
committed
Merge branch 'dotsimon/cancel-alert/OTP-19592' into maint-27
* dotsimon/cancel-alert/OTP-19592: Reduce log level of user_canceled alert Handle closure alerts in pre-connected states
2 parents 6db1989 + 3ea2060 commit 35fc382

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

lib/ssl/src/ssl_gen_statem.erl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,6 +1917,12 @@ log_alert(Level, Role, ProtocolName, StateName, #alert{role = Role} = Alert) ->
19171917
statename => StateName,
19181918
alert => Alert,
19191919
alerter => own}, Alert#alert.where);
1920+
log_alert(Level, Role, ProtocolName, StateName, #alert{description = ?USER_CANCELED} = Alert) ->
1921+
ssl_logger:log(info, Level, #{protocol => ProtocolName,
1922+
role => Role,
1923+
statename => StateName,
1924+
alert => Alert,
1925+
alerter => peer}, Alert#alert.where);
19201926
log_alert(Level, Role, ProtocolName, StateName, Alert) ->
19211927
ssl_logger:log(notice, Level, #{protocol => ProtocolName,
19221928
role => Role,

lib/ssl/src/tls_record_1_3.erl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,17 @@ decode_cipher_text(#ssl_tls{type = ?ALERT,
157157
{#ssl_tls{type = ?ALERT,
158158
version = ?TLS_1_3, %% Internally use real version
159159
fragment = <<?FATAL,?ILLEGAL_PARAMETER>>}, ConnectionStates0};
160-
%% TLS 1.3 server can receive a User Cancelled Alert when handshake is
161-
%% paused and then cancelled on the client side.
160+
%% TLS 1.3 server can receive Closure Alerts before the handshake is completed
162161
decode_cipher_text(#ssl_tls{type = ?ALERT,
163162
version = ?LEGACY_VERSION,
164-
fragment = <<?FATAL,?USER_CANCELED>>},
165-
ConnectionStates0) ->
163+
fragment = <<_Level,ClosureAlert>>},
164+
#{current_read :=
165+
#{security_parameters :=
166+
#security_parameters{application_traffic_secret = undefined}}} = ConnectionStates0)
167+
when (ClosureAlert == ?USER_CANCELED orelse ClosureAlert == ?CLOSE_NOTIFY) ->
166168
{#ssl_tls{type = ?ALERT,
167169
version = ?TLS_1_3, %% Internally use real version
168-
fragment = <<?FATAL,?USER_CANCELED>>}, ConnectionStates0};
170+
fragment = <<?FATAL,ClosureAlert>>}, ConnectionStates0};
169171
%% RFC8446 - TLS 1.3
170172
%% D.4. Middlebox Compatibility Mode
171173
%% - If not offering early data, the client sends a dummy

0 commit comments

Comments
 (0)