25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-28 16:34:13 +01:00

When TLS is required in s2s, add subelement to stream:features starttls

This commit is contained in:
Badlop 2010-12-10 17:27:15 +01:00
parent eb884c80d0
commit faf422202f

View File

@ -74,6 +74,7 @@
shaper, shaper,
tls = false, tls = false,
tls_enabled = false, tls_enabled = false,
tls_required = false,
tls_options = [], tls_options = [],
server, server,
authenticated = false, authenticated = false,
@ -151,12 +152,14 @@ init([{SockMod, Socket}, Opts]) ->
{value, {_, S}} -> S; {value, {_, S}} -> S;
_ -> none _ -> none
end, end,
StartTLS = case ejabberd_config:get_local_option(s2s_use_starttls) of {StartTLS, TLSRequired} = case ejabberd_config:get_local_option(s2s_use_starttls) of
undefined -> UseTls when (UseTls==undefined) or (UseTls==false) ->
false; {false, false};
UseStartTLS -> UseTls when (UseTls==true) or (UseTls==optional) ->
UseStartTLS {true, false};
end, required ->
{true, true}
end,
TLSOpts = case ejabberd_config:get_local_option(s2s_certfile) of TLSOpts = case ejabberd_config:get_local_option(s2s_certfile) of
undefined -> undefined ->
[]; [];
@ -171,6 +174,7 @@ init([{SockMod, Socket}, Opts]) ->
shaper = Shaper, shaper = Shaper,
tls = StartTLS, tls = StartTLS,
tls_enabled = false, tls_enabled = false,
tls_required = TLSRequired,
tls_options = TLSOpts, tls_options = TLSOpts,
timer = Timer}}. timer = Timer}}.
@ -214,9 +218,12 @@ wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) ->
StartTLS = if StartTLS = if
StateData#state.tls_enabled -> StateData#state.tls_enabled ->
[]; [];
true -> (not StateData#state.tls_enabled) and (not StateData#state.tls_required) ->
[{xmlelement, "starttls", [{xmlelement, "starttls", [{"xmlns", ?NS_TLS}], []}];
[{"xmlns", ?NS_TLS}], []}] (not StateData#state.tls_enabled) and StateData#state.tls_required ->
[{xmlelement, "starttls", [{"xmlns", ?NS_TLS}],
[{xmlelement, "required", [], []}]
}]
end, end,
send_element(StateData, send_element(StateData,
{xmlelement, "stream:features", [], {xmlelement, "stream:features", [],