diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2017-05-04 22:25:37 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-05-04 22:25:37 +0200 |
commit | 73b7edf9de59f97ccfdc59a71a6a4146b230ae81 (patch) | |
tree | fa9d0b2b3f6682f1648fbe7f35b76bbb41c7e9f3 /lib/pure/asyncnet.nim | |
parent | c0669326357cab1af0cc93bf562eeb5b7be484a0 (diff) | |
parent | c24dc7944aae2aa108b2638a9c70a5edf5e47915 (diff) | |
download | Nim-73b7edf9de59f97ccfdc59a71a6a4146b230ae81.tar.gz |
Merge branch 'devel' of github.com:nim-lang/Nim into devel
Diffstat (limited to 'lib/pure/asyncnet.nim')
-rw-r--r-- | lib/pure/asyncnet.nim | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/pure/asyncnet.nim b/lib/pure/asyncnet.nim index 11b7998b2..9f73bc3cf 100644 --- a/lib/pure/asyncnet.nim +++ b/lib/pure/asyncnet.nim @@ -647,9 +647,12 @@ when defineSsl: sslSetBio(socket.sslHandle, socket.bioIn, socket.bioOut) proc wrapConnectedSocket*(ctx: SslContext, socket: AsyncSocket, - handshake: SslHandshakeType) = + handshake: SslHandshakeType, + hostname: string = nil) = ## Wraps a connected socket in an SSL context. This function effectively ## turns ``socket`` into an SSL socket. + ## ``hostname`` should be specified so that the client knows which hostname + ## the server certificate should be validated against. ## ## This should be called on a connected socket, and will perform ## an SSL handshake immediately. @@ -660,6 +663,10 @@ when defineSsl: case handshake of handshakeAsClient: + if not hostname.isNil and not isIpAddress(hostname): + # 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, hostname) sslSetConnectState(socket.sslHandle) of handshakeAsServer: sslSetAcceptState(socket.sslHandle) |