Skip to content

Commit 9ee4481

Browse files
dotsimonIngelaAndin
authored andcommitted
Handle closure alerts in pre-connected states
1 parent 7b8942e commit 9ee4481

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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)