Skip to content

Commit d5b8832

Browse files
Merge pull request #13559 from rabbitmq/tls-header
Log clearer message if TLS client connects to AMQP port
2 parents 18533d4 + 11e56bd commit d5b8832

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

deps/rabbit/src/rabbit_reader.erl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,17 @@ handle_input({frame_payload, Type, Channel, PayloadSize}, Data, State) ->
11191119
handle_input(handshake, <<"AMQP", A, B, C, D, Rest/binary>>, State) ->
11201120
{Rest, version_negotiation({A, B, C, D}, State)};
11211121
handle_input(handshake, <<Other:8/binary, _/binary>>, #v1{sock = Sock}) ->
1122-
refuse_connection(Sock, {bad_header, Other});
1122+
Reason = case Other of
1123+
<<16#16, 16#03, _Ver2, _Len1, _Len2, 16#01, _, _>> ->
1124+
%% Looks like a TLS client hello.
1125+
detected_unexpected_tls_header;
1126+
<<"GET ", _URL/binary>> ->
1127+
%% Looks like an HTTP request.
1128+
detected_unexpected_http_header;
1129+
_ ->
1130+
bad_header
1131+
end,
1132+
refuse_connection(Sock, {Reason, Other});
11231133
handle_input(Callback, Data, _State) ->
11241134
throw({bad_input, Callback, Data}).
11251135

0 commit comments

Comments
 (0)