summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/net.nim20
1 files changed, 7 insertions, 13 deletions
diff --git a/lib/pure/net.nim b/lib/pure/net.nim
index 30d79ad9a..2b7b96c65 100644
--- a/lib/pure/net.nim
+++ b/lib/pure/net.nim
@@ -430,23 +430,17 @@ proc accept*(server: Socket, client: var Socket,
   var addrDummy = ""
   acceptAddr(server, client, addrDummy, flags)
 
-proc close*(socket: Socket, twoWay = true) =
+proc close*(socket: Socket) =
   ## Closes a socket.
-  ##
-  ## When used with a **SSL** socket, `twoWay` can be set to mandate a two-way
-  ## cryptographically secure shutdown, otherwise, a  "close notify" shutdown
-  ## alert is sent and the underlying socket is closed without waiting for a response.
-  ## This is acceptable under the TLS standard when the underlying connection is not
-  ## going to be use for further communications.
   when defined(ssl):
     if socket.isSSL:
       ErrClearError()
-      var res = SSLShutdown(socket.sslHandle)
-      if res == 0 and twoWay:
-        res = SSLShutdown(socket.sslHandle)
-        if res != 1:
-          socketError(socket, res)
-      elif res == 0:
+      # As we are closing the underlying socket immediately afterwards,
+      # it is valid, under the TLS standard, to perform a unidirectional
+      # shutdown i.e not wait for the peers "close notify" alert with a second
+      # call to SSLShutdown
+      let res = SSLShutdown(socket.sslHandle)
+      if res == 0:
         discard
       elif res != 1:
         socketError(socket, res)