Skip to content

Commit

Permalink
Borrow the initialization of XrdCryptossl, in order to share the
Browse files Browse the repository at this point in the history
OpenSSL threading setup
  • Loading branch information
Fabrizio Furano committed Jan 10, 2014
1 parent 7e029c1 commit 7ea8712
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/XrdHTTP.cmake
Expand Up @@ -20,7 +20,7 @@ set_target_properties(XrdHttp PROPERTIES
VERSION "${XRD_HTTP_VERSION}"
SOVERSION "${XRD_HTTP_SOVERSION}")

target_link_libraries(XrdHttp XrdMain dl ssl )
target_link_libraries(XrdHttp XrdMain XrdCrypto dl ssl )

# Install directive.
install(TARGETS XrdHttp
Expand Down
14 changes: 13 additions & 1 deletion src/XrdHTTP/XrdHttpProtocol.cc
Expand Up @@ -82,7 +82,7 @@ char *XrdHttpProtocol::secretkey = 0;
int XrdHttpProtocol::sslverifydepth = 9;
SSL_CTX *XrdHttpProtocol::sslctx = 0;
BIO *XrdHttpProtocol::sslbio_err = 0;

XrdCryptoFactory *XrdHttpProtocol::myCryptoFactory = 0;
XrdHttpSecXtractor *XrdHttpProtocol::secxtractor = 0;

static const unsigned char *s_server_session_id_context = (const unsigned char *) "XrdHTTPSessionCtx";
Expand Down Expand Up @@ -1263,6 +1263,18 @@ int verify_callback(int ok, X509_STORE_CTX * store) {

int XrdHttpProtocol::InitSecurity() {

#ifdef HAVE_XRDCRYPTO
#ifndef WIN32
// Borrow the initialization of XrdCryptossl, in order to share the
// OpenSSL threading bits
if (!(myCryptoFactory = XrdCryptoFactory::GetCryptoFactory("ssl"))) {
cerr << "Cannot instantiate crypto factory ssl" << endl;
exit(1);
}

#endif
#endif

SSL_library_init();
SSL_load_error_strings();
OpenSSL_add_all_ciphers();
Expand Down
4 changes: 3 additions & 1 deletion src/XrdHTTP/XrdHttpProtocol.hh
Expand Up @@ -41,7 +41,7 @@
#include "XrdSys/XrdSysError.hh"
#include "XrdSys/XrdSysPthread.hh"
#include "XrdSec/XrdSecInterface.hh"

#include "XrdCrypto/XrdCryptoFactory.hh"
#include "Xrd/XrdObject.hh"
#include "XrdXrootd/XrdXrootdBridge.hh"
#include "XrdOuc/XrdOucStream.hh"
Expand Down Expand Up @@ -216,6 +216,8 @@ private:
/// Flag to tell if the https handshake has finished, in the case of an https
/// connection being established
bool ssldone;

static XrdCryptoFactory *myCryptoFactory;
protected:


Expand Down

0 comments on commit 7ea8712

Please sign in to comment.