Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear OpenSSL error queue ahead of SSL_read/write/accept() #1464

Merged
merged 1 commit into from
Jun 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/XrdTls/XrdTlsSocket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ XrdTls::RC XrdTlsSocket::Connect(const char *thehost, std::string *eWhy)

// Do the connect.
//
do{int rc = SSL_connect( pImpl->ssl );
do{if (pImpl->isClient) ERR_clear_error();
int rc = SSL_connect( pImpl->ssl );
if (rc == 1) break;

ssler = Diagnose("TLS_Connect", rc, XrdTls::dbgSOK);
Expand Down Expand Up @@ -640,7 +641,8 @@ XrdTls::RC XrdTlsSocket::Read( char *buffer, size_t size, int &bytesRead )
// have to explicitly call SSL_connect or SSL_do_handshake.
//------------------------------------------------------------------------

do{int rc = SSL_read( pImpl->ssl, buffer, size );
do{if (pImpl->isClient) ERR_clear_error();
int rc = SSL_read( pImpl->ssl, buffer, size );

// Note that according to SSL whenever rc > 0 then SSL_ERROR_NONE can be
// returned to the caller. So, we short-circuit all the error handling.
Expand Down Expand Up @@ -785,7 +787,8 @@ XrdTls::RC XrdTlsSocket::Write( const char *buffer, size_t size,
// have to explicitly call SSL_connect or SSL_do_handshake.
//------------------------------------------------------------------------

do{int rc = SSL_write( pImpl->ssl, buffer, size );
do{if (pImpl->isClient) ERR_clear_error();
int rc = SSL_write( pImpl->ssl, buffer, size );

// Note that according to SSL whenever rc > 0 then SSL_ERROR_NONE can be
// returned to the caller. So, we short-circuit all the error handling.
Expand Down