To reproduce:
- Start a TLS/SSL server where the cacertfile option points to an invalid path
- Make a connection to the server. You will see an error logged such as this:
=ERROR REPORT==== 23-Dec-2017::16:31:46 === ** State machine <0.90.0> terminating ** Last event = {{call,{<0.88.0>,#Ref<0.889848035.289144833.238827>}}, {new_user,<0.91.0>}} ** When server state = {error,"tls_connection:format_status/2 crashed"} ** Reason for termination = error:function_clause ** Callback mode = state_functions ** Stacktrace = ** [{tls_connection,gen_handshake, [error, {call,{<0.88.0>,#Ref<0.889848035.289144833.238827>}}, {new_user,<0.91.0>}, {{options, {cacertfile, "/HAHAHA/lbakken/development/michaelklishin/tls-gen/basic/result/ca_certificate.pem", {error,enoent}}}, {state,server, {#Ref<0.889848035.289144833.238824>,<0.88.0>}, gen_tcp,tls_connection,tcp,tcp_closed,tcp_error,"localhost", 4000,#Port<0.2491>, {ssl_options,tls, [{3,3},{3,2},{3,1}],
In this line, the error is caught and the state machine attempts to enter the error state, but format_status doesn't handle this particular case.
It seems like format_status needs to be updated, or the call to enter_loop should be this when an error is caught:
gen_statem:enter_loop(?MODULE, [], {stop, Error}, [])
I tried the above but there were other errors as gen_statem tries to call tls_connection:stop/3 when I would expect the state machine to terminate as documented here
and here.
I'll see if I can get a PR done. Thanks!