diff options
author | Gabriele Santomaggio <g.santomaggio@gmail.com> | 2020-12-09 17:37:46 +0100 |
---|---|---|
committer | Luke Bakken <lbakken@pivotal.io> | 2020-12-10 08:36:13 -0800 |
commit | f47bc68550986090b87e1c979f91d2a8c28e512f (patch) | |
tree | 2d0de737026cfff6cdd43751c52b434240b0a167 | |
parent | fbb41addf26102cf360431ef91d8bb21667f209b (diff) | |
download | rabbitmq-server-git-f47bc68550986090b87e1c979f91d2a8c28e512f.tar.gz |
test sni
-rw-r--r-- | deps/rabbit/src/rabbit_reader.erl | 14 | ||||
-rw-r--r-- | deps/rabbit_common/src/rabbit_net.erl | 7 |
2 files changed, 19 insertions, 2 deletions
diff --git a/deps/rabbit/src/rabbit_reader.erl b/deps/rabbit/src/rabbit_reader.erl index c91dbbc105..569071ab8a 100644 --- a/deps/rabbit/src/rabbit_reader.erl +++ b/deps/rabbit/src/rabbit_reader.erl @@ -126,7 +126,7 @@ -define(CREATION_EVENT_KEYS, [pid, name, port, peer_port, host, peer_host, ssl, peer_cert_subject, peer_cert_issuer, - peer_cert_validity, auth_mechanism, ssl_protocol, + peer_cert_validity, auth_mechanism, ssl_sni, ssl_protocol, ssl_key_exchange, ssl_cipher, ssl_hash, protocol, user, vhost, timeout, frame_max, channel_max, client_properties, connected_at, node, user_who_performed_action]). @@ -1501,6 +1501,7 @@ i(SockStat, S) when SockStat =:= recv_oct; socket_info(fun (Sock) -> rabbit_net:getstat(Sock, [SockStat]) end, fun ([{_, I}]) -> I end, S); i(ssl, #v1{sock = Sock}) -> rabbit_net:is_ssl(Sock); +i(ssl_sni, #v1{sock = Sock}) -> sni_info(Sock); i(ssl_protocol, S) -> ssl_info(fun ({P, _}) -> P end, S); i(ssl_key_exchange, S) -> ssl_info(fun ({_, {K, _, _}}) -> K end, S); i(ssl_cipher, S) -> ssl_info(fun ({_, {_, C, _}}) -> C end, S); @@ -1570,6 +1571,17 @@ socket_info(Get, Select, #v1{sock = Sock}) -> {error, _} -> 0 end. +sni_info(Sock) -> + case rabbit_net:ssl_info(Sock, [sni_hostname]) of + nossl -> ''; + {error, _} -> ''; + {ok, Items} -> + io:format("Items value: ~p\n", [Items]), + SNI = proplists:get_value(sni_hostname, Items), + io:format("SNI value: ~s\n", [SNI]), + SNI + end. + ssl_info(F, #v1{sock = Sock}) -> case rabbit_net:ssl_info(Sock) of nossl -> ''; diff --git a/deps/rabbit_common/src/rabbit_net.erl b/deps/rabbit_common/src/rabbit_net.erl index 7685687ff0..1b8b4ee867 100644 --- a/deps/rabbit_common/src/rabbit_net.erl +++ b/deps/rabbit_common/src/rabbit_net.erl @@ -10,7 +10,7 @@ -include_lib("kernel/include/inet.hrl"). --export([is_ssl/1, ssl_info/1, controlling_process/2, getstat/2, +-export([is_ssl/1, ssl_info/1, ssl_info/2, controlling_process/2, getstat/2, recv/1, sync_recv/2, async_recv/3, port_command/2, getopts/2, setopts/2, send/2, close/1, fast_close/1, sockname/1, peername/1, peercert/1, connection_string/2, socket_ends/2, is_loopback/1, @@ -98,6 +98,11 @@ ssl_info(Sock) when ?IS_SSL(Sock) -> ssl_info(_Sock) -> nossl. +ssl_info(Sock, Items) when ?IS_SSL(Sock) -> + ssl:connection_information(Sock, Items); +ssl_info(_Sock, _Items) -> + nossl. + controlling_process(Sock, Pid) when ?IS_SSL(Sock) -> ssl:controlling_process(Sock, Pid); controlling_process(Sock, Pid) when is_port(Sock) -> |