aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssl/src/ssl_connection.erl
diff options
context:
space:
mode:
authorQijiang Fan <[email protected]>2014-12-30 22:40:28 +0800
committerIngela Anderton Andin <[email protected]>2015-05-12 13:57:25 +0200
commit4fe38c4b8b2c8024afb60990e598ff823743fd54 (patch)
treeea9c593b1a6ac3e76913c77dfce1caae97c41bf0 /lib/ssl/src/ssl_connection.erl
parent996380765561b1a0e3d215437d4560d2e7a72cfb (diff)
downloadotp-4fe38c4b8b2c8024afb60990e598ff823743fd54.tar.gz
otp-4fe38c4b8b2c8024afb60990e598ff823743fd54.tar.bz2
otp-4fe38c4b8b2c8024afb60990e598ff823743fd54.zip
ssl: add SNI server support
Diffstat (limited to 'lib/ssl/src/ssl_connection.erl')
-rw-r--r--lib/ssl/src/ssl_connection.erl16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/ssl/src/ssl_connection.erl b/lib/ssl/src/ssl_connection.erl
index 4a839872a6..2c0b1b6257 100644
--- a/lib/ssl/src/ssl_connection.erl
+++ b/lib/ssl/src/ssl_connection.erl
@@ -42,7 +42,8 @@
%% User Events
-export([send/2, recv/3, close/1, shutdown/2,
new_user/2, get_opts/2, set_opts/2, info/1, session_info/1,
- peer_certificate/1, renegotiation/1, negotiated_protocol/1, prf/5
+ peer_certificate/1, renegotiation/1, negotiated_protocol/1, prf/5,
+ sni_hostname/1
]).
-export([handle_session/7]).
@@ -161,6 +162,14 @@ recv(Pid, Length, Timeout) ->
sync_send_all_state_event(Pid, {recv, Length, Timeout}).
%%--------------------------------------------------------------------
+-spec sni_hostname(pid()) -> undefined | string().
+%%
+%% Description: Get the SNI hostname
+%%--------------------------------------------------------------------
+sni_hostname(Pid) when is_pid(Pid) ->
+ sync_send_all_state_event(Pid, sni_hostname).
+
+%%--------------------------------------------------------------------
-spec close(pid()) -> ok | {error, reason()}.
%%
%% Description: Close an ssl connection
@@ -845,7 +854,10 @@ handle_sync_event(session_info, _, StateName,
handle_sync_event(peer_certificate, _, StateName,
#state{session = #session{peer_certificate = Cert}}
= State) ->
- {reply, {ok, Cert}, StateName, State, get_timeout(State)}.
+ {reply, {ok, Cert}, StateName, State, get_timeout(State)};
+handle_sync_event(sni_hostname, _, StateName, #state{sni_hostname = SNIHostname} = State) ->
+ {reply, SNIHostname, StateName, State}.
+
handle_info({ErrorTag, Socket, econnaborted}, StateName,
#state{socket = Socket, transport_cb = Transport,