asyncnet, net: call SSL_shutdown only when connection established
This commit prevents "SSL_shutdown while in init" errors from happening. See https://github.com/openssl/openssl/issues/710#issuecomment-253897666
This commit is contained in:
parent
61f2f1f5c5
commit
82092b3bb7
4 changed files with 52 additions and 12 deletions
|
|
@ -713,7 +713,14 @@ proc close*(socket: AsyncSocket) =
|
|||
socket.fd.AsyncFD.closeSocket()
|
||||
when defineSsl:
|
||||
if socket.isSsl:
|
||||
let res = SSL_shutdown(socket.sslHandle)
|
||||
let res =
|
||||
# Don't call SSL_shutdown if the connection has not been fully
|
||||
# established, see:
|
||||
# https://github.com/openssl/openssl/issues/710#issuecomment-253897666
|
||||
if SSL_in_init(socket.sslHandle) == 0:
|
||||
SSL_shutdown(socket.sslHandle)
|
||||
else:
|
||||
0
|
||||
SSL_free(socket.sslHandle)
|
||||
if res == 0:
|
||||
discard
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue