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 the OpenSSL error queue in XrdCryptosslX509ParseBucket() #1465

Merged
merged 4 commits into from
Jun 11, 2021

Conversation

jthiltges
Copy link
Contributor

Regarding the OpenSSL ERR_clear_error() overhead introduced in #1464:

This PR should clear the OpenSSL error queue in XrdCryptosslX509ParseBucket(), along with reverting the ERR_clear_error() calls in XrdTlsSocket.

So far, I'm unable to reproduce the TLS error on our local xcache with this patch (on the latest experimental, xrootd-5.2.1-0.experimental.2679300.76d03f61). This certainly could use some thorough testing to confirm. @osschar

@osschar
Copy link
Contributor

osschar commented Jun 8, 2021

I thought the errors we are seeing now happen on UNL gridftps. But I can sure pull this in and run it on UCSD caches.

@xrootd-dev
Copy link

xrootd-dev commented Jun 8, 2021 via email

@jthiltges
Copy link
Contributor Author

My goal was to get rid of the ERR_clear_error() calls in XrdTlsSocket. If the error queue clearing in f74d453 is sufficient, then this PR can be ignored. I'll do some testing.

@xrootd-dev
Copy link

xrootd-dev commented Jun 9, 2021 via email

@osschar
Copy link
Contributor

osschar commented Jun 9, 2021

Andy, remember, John is also seeing these errors in XCache when auth is enabled. I don't know if http access is enabled there as well.

@xrootd-dev
Copy link

xrootd-dev commented Jun 9, 2021 via email

@jthiltges
Copy link
Contributor Author

I did some testing with master (bbf477b) and reverting the XrdTlsSocket ERR_clear_error() patch (9d355f6). I'm still seeing error:0906D06C:PEM routines:PEM_read_bio:no start line in the OpenSSL error queue ahead of XrdTls SSL_connect/read/write calls.

I'm suspecting that Tls::ClearErrorQueue() is not always called after GSI calls.

if( info->encrypted || ( info->serverFlags & kXR_gotoTLS ) ||
( info->serverFlags & kXR_tlsLogin ) )
//------------------------------------------------------------------------
// Clear the SSL error queue of the calling thread, as there might be
// some leftover from the authentication!
//------------------------------------------------------------------------
Tls::ClearErrorQueue();

It turns out that while our servers have TLS configured (serverFlags = 3592421377), our local redirector does not (serverFlags = 3145730).

XrdCl::XRootDTransport::DoAuthentication calls XrdSecProtocolgsi::getCredentials(), but if the server doesn't have TLS flags, the client doesn't call Tls::ClearErrorQueue().

That would explain why this PR seemed to address the issue, since it puts the SSL error clearing further down.

@simonmichal
Copy link
Contributor

@jthiltges : ahh, ok, I see your point, the error queue is cleared only if the channel is encrypted, however since multiple channels share the same event-loop thread it still may interfere with another channel that is encrypted

Could you try removing the if statement:

if( info->encrypted || ( info->serverFlags & kXR_gotoTLS ) ||
( info->serverFlags & kXR_tlsLogin ) )

and see if this helps?

XrdSecProtocolgsi::getCredentials() will leave OpenSSL errors on the queue,
even with non-encrypted channels. Clean up the queue to avoid affecting
other TLS traffic.
@jthiltges
Copy link
Contributor Author

  • Reverted the changes to XrdCryptosslX509ParseBucket()
    • Handling the OpenSSL error queue close to where the errors happen still appeals to me
  • Added a Tls::ClearErrorQueue() call to CleanUpAuthentication()
    • This seemed necessary if the authentication returns early due to an error
  • Removed the if from the two places Tls::ClearErrorQueue() is called
    • I'm not certain that both places need the change

I cannot reproduce the TLS errors with this revised PR.

@abh3
Copy link
Member

abh3 commented Jun 11, 2021

Thanks JT for all the work! When we meet in person again, I'll buy you a couple of beers :-)

@simonmichal
Copy link
Contributor

Looks solid :-) Thanks a lot, great job!

@simonmichal simonmichal merged commit dded1e6 into xrootd:master Jun 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants