Skip to content

Commit

Permalink
check if EAP_success is also reflected by a TLS successfull connection
Browse files Browse the repository at this point in the history
  • Loading branch information
ziopio committed Jun 15, 2023
1 parent 876a40f commit 58c623d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/erl_supplicant_eap.erl
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,16 @@ process_msg(?Response, <<Type:8/unsigned, TypeData/binary>>, Id, S) ->
?LOG_DEBUG("EAP responce ~p type: ~p", [Id, Type]),
handle_responce(Type, TypeData, Id, S);
process_msg(?Success, <<>>, Id, S) ->
?LOG_DEBUG("EAP SUCCESS: ~p", [Id]),
erl_supplicant_pacp:eap_success(),
erl_supplicant_eap_tls:stop(),
clear_timer(S#state{eap_state = success});
case erl_supplicant_eap_tls:is_tls_enstablished() of
false ->
?LOG_WARNING("Ignoring EAP SUCCESS: tls did not finish"),
S;
true ->
?LOG_DEBUG("EAP SUCCESS: ~p", [Id]),
erl_supplicant_pacp:eap_success(),
erl_supplicant_eap_tls:stop(),
clear_timer(S#state{eap_state = success})
end;
process_msg(?Failure, <<>>, Id, S) ->
?LOG_DEBUG("EAP FAILURE: ~p", [Id]),
erl_supplicant_pacp:eap_fail(),
Expand Down
9 changes: 9 additions & 0 deletions src/erl_supplicant_eap_tls.erl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
-export([start_link/0]).
-export([handle_request/1]).
-export([handle_responce/1]).
-export([is_tls_enstablished/0]).
-export([stop/0]).

-behaviour(gen_server).
Expand Down Expand Up @@ -69,6 +70,9 @@ handle_request(Request) ->
handle_responce(_) ->
error(not_implemented).

is_tls_enstablished() ->
gen_server:call(?MODULE, ?FUNCTION_NAME).

stop() ->
gen_server:cast(?MODULE, ?FUNCTION_NAME).

Expand Down Expand Up @@ -106,6 +110,11 @@ init([]) ->

handle_call({handle_request, Binary}, From, _S) ->
do_handle_request(Binary, From, _S);
handle_call(is_tls_enstablished, _, #state{tls_connection = undefined} = S) ->
{reply, false, S};
handle_call(is_tls_enstablished, _,
#state{tls_connection = {sslsocket, _, _}} = S) ->
{reply, true, S};
handle_call(Msg, From, State) ->
?LOG_ERROR("Unexpected call ~p from ~p",[Msg, From]),
{reply, error, State}.
Expand Down

0 comments on commit 58c623d

Please sign in to comment.