Skip to content
This repository was archived by the owner on Nov 16, 2020. It is now read-only.

Commit b60412f

Browse files
committed
Add support for client certificate authentication
Fixes #116 Ensure your config has `{ssl_cert_login, true}` in the `rabbitmq_web_stomp` section.
1 parent 526a034 commit b60412f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/rabbit_web_stomp_handler.erl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,12 @@ init_processor_state(#state{socket=Sock, peername=PeerAddr, auth_hd=AuthHd}) ->
9595
ok
9696
end,
9797

98+
SSLLogin = application:get_env(rabbitmq_stomp, ssl_cert_login, false),
99+
StompConfig0 = #stomp_configuration{ssl_cert_login = SSLLogin, implicit_connect = false},
98100
UseHTTPAuth = application:get_env(rabbitmq_web_stomp, use_http_auth, false),
99-
StompConfig0 = #stomp_configuration{implicit_connect = false},
100101
UserConfig = application:get_env(rabbitmq_stomp, default_user, undefined),
101102
StompConfig1 = rabbit_stomp:parse_default_user(UserConfig, StompConfig0),
102-
StompConfig = case UseHTTPAuth of
103+
StompConfig2 = case UseHTTPAuth of
103104
true ->
104105
case AuthHd of
105106
undefined ->
@@ -118,10 +119,11 @@ init_processor_state(#state{socket=Sock, peername=PeerAddr, auth_hd=AuthHd}) ->
118119
end,
119120

120121
AdapterInfo = amqp_connection:socket_adapter_info(Sock, {'Web STOMP', 0}),
121-
122+
RealSocket = rabbit_net:unwrap_socket(Sock),
123+
SSLLoginName = rabbit_stomp_reader:ssl_login_name(RealSocket, StompConfig2),
122124
ProcessorState = rabbit_stomp_processor:initial_state(
123-
StompConfig,
124-
{SendFun, AdapterInfo, none, PeerAddr}),
125+
StompConfig2,
126+
{SendFun, AdapterInfo, SSLLoginName, PeerAddr}),
125127
{ok, ProcessorState}.
126128

127129
websocket_handle({text, Data}, State) ->

0 commit comments

Comments
 (0)