Skip to content

Commit c7c0e90

Browse files
committed
xmpp_stream_in: Announce SASL2 over non-TLS
Don't forget to announce the SASL2 feature over non-TLS connections if the 'allow_unencrypted_sasl2' option is enabled.
1 parent ff0dd53 commit c7c0e90

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/xmpp_stream_in.erl

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,17 +1266,26 @@ send_features(#{stream_version := {1,0},
12661266
TLSAvailable = is_starttls_available(State),
12671267
TLSRequired = is_starttls_required(State),
12681268
Sasl2 = maps:is_key(sasl2_stream_from, State),
1269+
AllowUnencryptedSasl2 = allow_unencrypted_sasl2(State),
12691270
if
12701271
(not Encrypted) andalso TLSRequired ->
12711272
send_pkt(State, #stream_features{sub_els = get_tls_feature(State)});
12721273
true ->
12731274
{Features, State2} =
1274-
case {Encrypted, Sasl2, TLSAvailable} of
1275-
{true, true, _} -> {get_sasl2_feature(State), init_channel_bindings(State)};
1276-
{false, true, false} -> {[], disable_sasl2(State)};
1277-
{false, _, true} -> {get_tls_feature(State), State};
1278-
{true, _, _} -> {[], init_channel_bindings(State)};
1279-
_ -> {[], State}
1275+
case {Encrypted, Sasl2, AllowUnencryptedSasl2, TLSAvailable} of
1276+
{false, true, true, true} ->
1277+
{get_tls_feature(State) ++ get_sasl2_feature(State),
1278+
init_channel_bindings(State)};
1279+
{_, true, _, _} when Encrypted; AllowUnencryptedSasl2 ->
1280+
{get_sasl2_feature(State), init_channel_bindings(State)};
1281+
{false, true, false, false} ->
1282+
{[], disable_sasl2(State)};
1283+
{false, _, _, true} ->
1284+
{get_tls_feature(State), State};
1285+
{true, _, _, _} ->
1286+
{[], init_channel_bindings(State)};
1287+
_ ->
1288+
{[], State}
12801289
end,
12811290
Features2 =
12821291
get_sasl_feature(State2) ++

0 commit comments

Comments
 (0)