asyncnet, net: clear openssl error queue before performing I/O

Per SSL_get_error(3):

  The current thread's error queue must be empty before the TLS/SSL I/O
  operation is attempted, or SSL_get_error() will not work reliably.

There has been records of not clearing the error queue causing weird SSL
errors when there shouldn't be any, see:

https://github.com/openssl/openssl/issues/11889
This commit is contained in:
Leorize
2020-06-03 15:11:10 -05:00
parent b823b7c78f
commit 476be6cc27
3 changed files with 9 additions and 0 deletions

View File

@@ -61,6 +61,7 @@ when not defined(windows):
var ssl: SslPtr = SSL_new(ctx.context)
discard SSL_set_fd(ssl, client.getFd())
log "server: accepting connection"
ErrClearError()
if SSL_accept(ssl) <= 0:
ERR_print_errors_fp(stderr)
else: