diff options
author | Magnus Henoch <[email protected]> | 2016-02-03 18:20:39 +0000 |
---|---|---|
committer | Magnus Henoch <[email protected]> | 2016-03-17 16:48:24 +0000 |
commit | 4b3a9cbeaa101603b6eaf6d68976e90780d85fc2 (patch) | |
tree | c2662280a2d89933f56ee90cc9b8465aa83ad4da /lib/ssl/src | |
parent | ca946a3c64573295d289dbd556c375ec5259c4b3 (diff) | |
download | otp-4b3a9cbeaa101603b6eaf6d68976e90780d85fc2.tar.gz otp-4b3a9cbeaa101603b6eaf6d68976e90780d85fc2.tar.bz2 otp-4b3a9cbeaa101603b6eaf6d68976e90780d85fc2.zip |
Allow passing verify_fun for TLS distribution
Accept a value of the form {Module, Function, State} from the command
line. This is different from the {Fun, State} that ssl:connect etc
expect, since there's no clean way to parse a fun from a command line
argument.
Diffstat (limited to 'lib/ssl/src')
-rw-r--r-- | lib/ssl/src/ssl_tls_dist_proxy.erl | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/ssl/src/ssl_tls_dist_proxy.erl b/lib/ssl/src/ssl_tls_dist_proxy.erl index 75562d6fae..33204aa881 100644 --- a/lib/ssl/src/ssl_tls_dist_proxy.erl +++ b/lib/ssl/src/ssl_tls_dist_proxy.erl @@ -396,6 +396,10 @@ ssl_options(server, ["server_verify", Value|T]) -> [{verify, atomize(Value)} | ssl_options(server,T)]; ssl_options(client, ["client_verify", Value|T]) -> [{verify, atomize(Value)} | ssl_options(client,T)]; +ssl_options(server, ["server_verify_fun", Value|T]) -> + [{verify_fun, verify_fun(Value)} | ssl_options(server,T)]; +ssl_options(client, ["client_verify_fun", Value|T]) -> + [{verify_fun, verify_fun(Value)} | ssl_options(client,T)]; ssl_options(server, ["server_reuse_sessions", Value|T]) -> [{reuse_sessions, atomize(Value)} | ssl_options(server,T)]; ssl_options(client, ["client_reuse_sessions", Value|T]) -> @@ -428,6 +432,20 @@ atomize(List) when is_list(List) -> atomize(Atom) when is_atom(Atom) -> Atom. +termify(String) when is_list(String) -> + {ok, Tokens, _} = erl_scan:string(String ++ "."), + {ok, Term} = erl_parse:parse_term(Tokens), + Term. + +verify_fun(Value) -> + case termify(Value) of + {Mod, Func, State} when is_atom(Mod), is_atom(Func) -> + Fun = fun Mod:Func/3, + {Fun, State}; + _ -> + error(malformed_ssl_dist_opt, [Value]) + end. + flush_old_controller(Pid, Socket) -> receive {tcp, Socket, Data} -> |