diff options
author | Erlang/OTP <[email protected]> | 2019-06-03 11:34:51 +0200 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2019-06-03 11:34:51 +0200 |
commit | b931c0c741aadb29cd29a42d82ee2676048caac7 (patch) | |
tree | a454124ce8dc8e169a72655840a59f99e14e371f /lib/ssl/src/ssl_alert.erl | |
parent | a4a35c8cfd19781875a84dda9db56fe839004d64 (diff) | |
parent | a04228cc4ebe53af4e676cc6a7642e3a1025cc3f (diff) | |
download | otp-b931c0c741aadb29cd29a42d82ee2676048caac7.tar.gz otp-b931c0c741aadb29cd29a42d82ee2676048caac7.tar.bz2 otp-b931c0c741aadb29cd29a42d82ee2676048caac7.zip |
Merge branch 'ingela/ssl/alert-strings/OTP-15844' into maint-21
* ingela/ssl/alert-strings/OTP-15844:
Export named_curve/0
ssl: Export type that user may want to use
ssl: Returned "alert error string" should be same as logged alert string
Diffstat (limited to 'lib/ssl/src/ssl_alert.erl')
-rw-r--r-- | lib/ssl/src/ssl_alert.erl | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/lib/ssl/src/ssl_alert.erl b/lib/ssl/src/ssl_alert.erl index 2a20d13cd5..81167b5ba3 100644 --- a/lib/ssl/src/ssl_alert.erl +++ b/lib/ssl/src/ssl_alert.erl @@ -32,7 +32,11 @@ -include("ssl_record.hrl"). -include("ssl_internal.hrl"). --export([decode/1, own_alert_txt/1, alert_txt/1, reason_code/2]). +-export([decode/1, + own_alert_txt/1, + alert_txt/1, + alert_txt/4, + reason_code/4]). %%==================================================================== %% Internal application API @@ -48,20 +52,29 @@ decode(Bin) -> decode(Bin, [], 0). %%-------------------------------------------------------------------- -%% -spec reason_code(#alert{}, client | server) -> -%% {tls_alert, unicode:chardata()} | closed. -%-spec reason_code(#alert{}, client | server) -> closed | {essl, string()}. +-spec reason_code(#alert{}, client | server, ProtocolName::string(), StateName::atom()) -> + {tls_alert, {atom(), unicode:chardata()}} | closed. %% %% Description: Returns the error reason that will be returned to the %% user. %%-------------------------------------------------------------------- -reason_code(#alert{description = ?CLOSE_NOTIFY}, _) -> +reason_code(#alert{description = ?CLOSE_NOTIFY}, _, _, _) -> closed; -reason_code(#alert{description = Description, role = Role} = Alert, Role) -> - {tls_alert, {description_atom(Description), own_alert_txt(Alert)}}; -reason_code(#alert{description = Description} = Alert, Role) -> - {tls_alert, {description_atom(Description), alert_txt(Alert#alert{role = Role})}}. +reason_code(#alert{description = Description, role = Role} = Alert, Role, ProtocolName, StateName) -> + Txt = lists:flatten(alert_txt(ProtocolName, Role, StateName, own_alert_txt(Alert))), + {tls_alert, {description_atom(Description), Txt}}; +reason_code(#alert{description = Description} = Alert, Role, ProtocolName, StateName) -> + Txt = lists:flatten(alert_txt(ProtocolName, Role, StateName, alert_txt(Alert))), + {tls_alert, {description_atom(Description), Txt}}. + +%%-------------------------------------------------------------------- +-spec alert_txt(string(), server | client, StateNam::atom(), string()) -> string(). +%% +%% Description: Generates alert text for log or string part of error return. +%%-------------------------------------------------------------------- +alert_txt(ProtocolName, Role, StateName, Txt) -> + io_lib:format("~s ~p: In state ~p ~s\n", [ProtocolName, Role, StateName, Txt]). %%-------------------------------------------------------------------- -spec own_alert_txt(#alert{}) -> string(). |