# test.nim
import std/[asyncdispatch, asyncnet]
import std/random # ← this line breaks everything
proc main() {.async.} =
let sock = newAsyncSocket()
await sock.connect("stream.binance.com", Port(9443))
let ctx = newContext(protSSLv23)
wrapConnectedSocket(ctx, sock, handshakeAsClient, "stream.binance.com")
echo "SSL OK"
waitFor main()
Compile and run:
nim c -d:ssl -r test.nim
Error: unhandled exception: error:140040E5:SSL routines:CONNECT_CR_SRVR_HELLO:ssl handshake failure [SslError]
random module's static initializer appears to corrupt OpenSSL's global state at the C lib level. The ws library imports random for masking key generation, which poisons any downstream project using it with SSL.