noxxi / p5-io-socket-ssl

IO::Socket::SSL Perl Module
36 stars 59 forks source link

The SSL error queue isn't cleared when unexpected EOF is encountered during read operation #145

Closed Yaribz closed 10 months ago

Yaribz commented 10 months ago

Since OpenSSL 3.0, an "unexpected eof while reading" error is put in OpenSSL error queue when an EOF is encountered while performing a SSL read operation. The _generic_read function correctly checks for both error codes SSL_ERROR_SYSCALL (OpenSSL < 3.0) and SSL_ERROR_SSL (OpenSSL >= 3.0) to detect unexpected EOF and emulate zero-length read in this case, however it doesn't clear the error queue.

When OpenSSL 3.0+ is used, it means SSL errors can leak to other unrelated places where the SSL error queue is checked. For example it can lead to SSL connections being wrongfully closed at the same time an EOF is encountered unexpectedly on an unrelated SSL connection.