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
Merged
Show file tree
Hide file tree
Changes from 2 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
25 changes: 11 additions & 14 deletions src/XrdCl/XrdClXRootDTransport.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2241,13 +2241,11 @@ namespace XrdCl
"[%s] Authenticated with %s.", hsData->streamName.c_str(),
protocolName.c_str() );

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();
//--------------------------------------------------------------------
// Clear the SSL error queue of the calling thread, as there might be
// some leftover from the authentication!
//--------------------------------------------------------------------
Tls::ClearErrorQueue();

return XRootDStatus();
}
Expand Down Expand Up @@ -2311,13 +2309,11 @@ namespace XrdCl
MarshallRequest( msg );
delete credentials;

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();
//------------------------------------------------------------------------
// Clear the SSL error queue of the calling thread, as there might be
// some leftover from the authentication!
//------------------------------------------------------------------------
Tls::ClearErrorQueue();

return XRootDStatus( stOK, suContinue );
}
Expand Down Expand Up @@ -2425,6 +2421,7 @@ namespace XrdCl
info->authProtocol = 0;
info->authParams = 0;
info->authEnv = 0;
Tls::ClearErrorQueue();
return Status();
}

Expand Down
15 changes: 0 additions & 15 deletions src/XrdCrypto/XrdCryptosslAux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include "XrdCrypto/XrdCryptosslX509.hh"
#include "XrdCrypto/XrdCryptosslTrace.hh"
#include "XrdTls/XrdTlsPeerCerts.hh"
#include <openssl/err.h>
#include <openssl/pem.h>

// Error code from verification set by verify callback function
Expand Down Expand Up @@ -606,7 +605,6 @@ int XrdCryptosslX509ParseBucket(XrdSutBucket *b, XrdCryptoX509Chain *chain)
if (BIO_write(bmem,(const void *)(b->buffer),b->size) != b->size) {
DEBUG("problems writing data to BIO");
BIO_free(bmem);
ERR_clear_error();
return nci;
}

Expand All @@ -623,18 +621,12 @@ int XrdCryptosslX509ParseBucket(XrdSutBucket *b, XrdCryptoX509Chain *chain)
} else {
DEBUG("could not create certificate: memory exhausted?");
BIO_free(bmem);
ERR_clear_error();
return nci;
}
// reset cert otherwise the next one is not fetched
xcer = 0;
}

// Clear OpenSSL error queue from PEM_read_bio_X509() loop end condition
if (ERR_GET_REASON(ERR_peek_last_error()) == PEM_R_NO_START_LINE) {
ERR_clear_error();
}

// If we found something, and we are asked to extract a key,
// refill the BIO and search again for the key (this is mandatory
// as read operations modify the BIO contents; a read-only BIO
Expand Down Expand Up @@ -698,13 +690,6 @@ int XrdCryptosslX509ParseBucket(XrdSutBucket *b, XrdCryptoX509Chain *chain)
// Cleanup
BIO_free(bmem);

// Report and clear any other OpenSSL errors on the queue
char eBuff[120]; int eCode;
while ((eCode = ERR_get_error())) {
ERR_error_string_n(eCode, eBuff, sizeof(eBuff));
DEBUG("TLS error: " << eBuff);
}

// We are done
return nci;
}
Expand Down