Adjustments to #2610.
This commit is contained in:
parent
8853dfb353
commit
68f583ddb7
2 changed files with 15 additions and 5 deletions
|
|
@ -472,7 +472,16 @@ when defined(ssl):
|
||||||
socket.bioOut = bioNew(bio_s_mem())
|
socket.bioOut = bioNew(bio_s_mem())
|
||||||
sslSetBio(socket.sslHandle, socket.bioIn, socket.bioOut)
|
sslSetBio(socket.sslHandle, socket.bioIn, socket.bioOut)
|
||||||
|
|
||||||
proc wrapSocket*(ctx: SslContext, socket: AsyncSocket, handshake: SslHandshakeType) =
|
proc wrapConnectedSocket*(ctx: SslContext, socket: AsyncSocket,
|
||||||
|
handshake: SslHandshakeType) =
|
||||||
|
## Wraps a connected socket in an SSL context. This function effectively
|
||||||
|
## turns ``socket`` into an SSL socket.
|
||||||
|
##
|
||||||
|
## This should be called on a connected socket, and will perform
|
||||||
|
## an SSL handshake immediately.
|
||||||
|
##
|
||||||
|
## **Disclaimer**: This code is not well tested, may be very unsafe and
|
||||||
|
## prone to security vulnerabilities.
|
||||||
wrapSocket(ctx, socket)
|
wrapSocket(ctx, socket)
|
||||||
|
|
||||||
case handshake
|
case handshake
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ type
|
||||||
proc isIpAddress*(address_str: string): bool {.tags: [].}
|
proc isIpAddress*(address_str: string): bool {.tags: [].}
|
||||||
proc parseIpAddress*(address_str: string): IpAddress
|
proc parseIpAddress*(address_str: string): IpAddress
|
||||||
proc socketError*(socket: Socket, err: int = -1, async = false,
|
proc socketError*(socket: Socket, err: int = -1, async = false,
|
||||||
lastError = (-1).OSErrorCode): void
|
lastError = (-1).OSErrorCode): void
|
||||||
|
|
||||||
proc isDisconnectionError*(flags: set[SocketFlag],
|
proc isDisconnectionError*(flags: set[SocketFlag],
|
||||||
lastError: OSErrorCode): bool =
|
lastError: OSErrorCode): bool =
|
||||||
|
|
@ -259,9 +259,10 @@ when defined(ssl):
|
||||||
if SSLSetFd(socket.sslHandle, socket.fd) != 1:
|
if SSLSetFd(socket.sslHandle, socket.fd) != 1:
|
||||||
raiseSSLError()
|
raiseSSLError()
|
||||||
|
|
||||||
proc wrapSocket*(ctx: SSLContext, socket: Socket, handshake: SslHandshakeType) =
|
proc wrapConnectedSocket*(ctx: SSLContext, socket: Socket,
|
||||||
## Wraps a socket in an SSL context. This function effectively turns
|
handshake: SslHandshakeType) =
|
||||||
## ``socket`` into an SSL socket.
|
## Wraps a connected socket in an SSL context. This function effectively
|
||||||
|
## turns ``socket`` into an SSL socket.
|
||||||
##
|
##
|
||||||
## This should be called on a connected socket, and will perform
|
## This should be called on a connected socket, and will perform
|
||||||
## an SSL handshake immediately.
|
## an SSL handshake immediately.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue