summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@gmail.com>2017-02-08 00:04:40 +0100
committerDominik Picheta <dominikpicheta@gmail.com>2017-02-08 00:04:40 +0100
commit0535b6b6bf5b533f1238832e5f92cdd50e3fa1de (patch)
tree612323f3b438007971f96f0d75f02b3d07afeb67 /lib
parent4ef86042f270552b1d741738118c9ae8a2758cc4 (diff)
downloadNim-0535b6b6bf5b533f1238832e5f92cdd50e3fa1de.tar.gz
Implement SSL SNI hostname setting for asyncnet.
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/asyncnet.nim5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/pure/asyncnet.nim b/lib/pure/asyncnet.nim
index 7e2c2f338..2d5c65001 100644
--- a/lib/pure/asyncnet.nim
+++ b/lib/pure/asyncnet.nim
@@ -253,6 +253,11 @@ proc connect*(socket: AsyncSocket, address: string, port: Port) {.async.} =
   await connect(socket.fd.AsyncFD, address, port, socket.domain)
   if socket.isSsl:
     when defineSsl:
+      if not isIpAddress(address):
+        # Set the SNI address for this connection. This call can fail if
+        # we're not using TLSv1+.
+        discard SSL_set_tlsext_host_name(socket.sslHandle, address)
+
       let flags = {SocketFlag.SafeDisconn}
       sslSetConnectState(socket.sslHandle)
       sslLoop(socket, flags, sslDoHandshake(socket.sslHandle))