From a767abb47e6d9a0817d37413e1b5c1d338b362d8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= <essen@ninenines.eu>
Date: Wed, 4 Jul 2018 12:33:30 +0200
Subject: Enable TLS upgrades via ranch_ssl:handshake/3

Based on the work done by @juhlig.
---
 doc/src/guide/transports.asciidoc | 11 +++++++++++
 1 file changed, 11 insertions(+)

(limited to 'doc/src/guide/transports.asciidoc')

diff --git a/doc/src/guide/transports.asciidoc b/doc/src/guide/transports.asciidoc
index f5bb17e..70efa1b 100644
--- a/doc/src/guide/transports.asciidoc
+++ b/doc/src/guide/transports.asciidoc
@@ -144,6 +144,17 @@ possible to use a file descriptor opened in raw mode:
 {ok, RawFile} = file:open(Filename, [raw, read, binary]),
 {ok, SentBytes} = Transport:sendfile(Socket, RawFile, Offset, Bytes, Opts).
 
+=== Upgrading a TCP socket to SSL
+
+A connected TCP socket can be upgraded to a SSL socket via the function
+`ranch_ssl:handshake/3`. The socket *must* be in `{active, false}` mode
+before telling the client that the server is ready to upgrade in order
+to avoid race conditions.
+
+.Performing a TLS handshake on a TCP socket
+[source,erlang]
+{ok, NewSocket} = ranch_ssl:handshake(Socket, SslOpts, 5000).
+
 === Writing a transport handler
 
 A transport handler is a module implementing the `ranch_transport` behavior.
-- 
cgit v1.2.3

