Skip to content

Commit

Permalink
[XrdCl] Implement TLS encryption.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmichal committed Jun 21, 2019
1 parent 4f163e3 commit 2cdd780
Show file tree
Hide file tree
Showing 27 changed files with 2,356 additions and 226 deletions.
10 changes: 6 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ include( XrdSec )
include( XrdXml )
include( XrdHeaders )

add_subdirectory( XrdTls )

if( BUILD_CRYPTO )
include( XrdSecgsi )
endif()
Expand All @@ -19,13 +21,13 @@ endif()

if( ENABLE_XRDCL )
add_subdirectory( XrdCl )
add_subdirectory( api_test )
endif()

if( XRDCLHTTP_SUBMODULE )
add_subdirectory( XrdClHttp )
endif()


if( NOT XRDCL_ONLY )
include( XrdClient )

Expand All @@ -49,9 +51,9 @@ if( NOT XRDCL_ONLY )
include( XrdMacaroons )
endif()

if( XRDCEPH_SUBMODULE )
add_subdirectory( XrdCeph )
endif()
if( XRDCEPH_SUBMODULE )
add_subdirectory( XrdCeph )
endif()
endif()

#-------------------------------------------------------------------------------
Expand Down
116 changes: 60 additions & 56 deletions src/XrdCl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,62 +29,64 @@ endif()
add_library(
XrdCl
SHARED
XrdClLog.cc XrdClLog.hh
XrdClUtils.cc XrdClUtils.hh
XrdClOptimizers.hh
XrdClConstants.hh
XrdClEnv.cc XrdClEnv.hh
XrdClDefaultEnv.cc XrdClDefaultEnv.hh
XrdClURL.cc XrdClURL.hh
XrdClStatus.cc XrdClStatus.hh
XrdClSocket.cc XrdClSocket.hh
XrdClPoller.hh
XrdClPollerFactory.cc XrdClPollerFactory.hh
XrdClPollerBuiltIn.cc XrdClPollerBuiltIn.hh
XrdClPostMaster.cc XrdClPostMaster.hh
XrdClPostMasterInterfaces.hh
XrdClChannel.cc XrdClChannel.hh
XrdClStream.cc XrdClStream.hh
XrdClXRootDTransport.cc XrdClXRootDTransport.hh
XrdClInQueue.cc XrdClInQueue.hh
XrdClOutQueue.cc XrdClOutQueue.hh
XrdClTaskManager.cc XrdClTaskManager.hh
XrdClSIDManager.cc XrdClSIDManager.hh
XrdClFileSystem.cc XrdClFileSystem.hh
XrdClXRootDMsgHandler.cc XrdClXRootDMsgHandler.hh
XrdClBuffer.hh
XrdClMessage.hh
XrdClMessageUtils.cc XrdClMessageUtils.hh
XrdClXRootDResponses.cc XrdClXRootDResponses.hh
XrdClRequestSync.hh
XrdClFile.cc XrdClFile.hh
XrdClFileStateHandler.cc XrdClFileStateHandler.hh
XrdClCopyProcess.cc XrdClCopyProcess.hh
XrdClClassicCopyJob.cc XrdClClassicCopyJob.hh
XrdClThirdPartyCopyJob.cc XrdClThirdPartyCopyJob.hh
XrdClAsyncSocketHandler.cc XrdClAsyncSocketHandler.hh
XrdClChannelHandlerList.cc XrdClChannelHandlerList.hh
XrdClForkHandler.cc XrdClForkHandler.hh
XrdClCheckSumManager.cc XrdClCheckSumManager.hh
XrdClTransportManager.cc XrdClTransportManager.hh
XrdClSyncQueue.hh
XrdClJobManager.cc XrdClJobManager.hh
XrdClResponseJob.hh
XrdClFileTimer.cc XrdClFileTimer.hh
XrdClUglyHacks.hh
XrdClPlugInInterface.hh
XrdClPlugInManager.cc XrdClPlugInManager.hh
XrdClPropertyList.hh
XrdClCopyJob.hh
XrdClFileSystemUtils.cc XrdClFileSystemUtils.hh
XrdClTPFallBackCopyJob.cc XrdClTPFallBackCopyJob.hh
XrdClMetalinkRedirector.cc XrdClMetalinkRedirector.hh
XrdClRedirectorRegistry.cc XrdClRedirectorRegistry.hh
XrdClZipArchiveReader.cc XrdClZipArchiveReader.hh
XrdClXCpCtx.cc XrdClXCpCtx.hh
XrdClXCpSrc.cc XrdClXCpSrc.hh
XrdClLocalFileHandler.cc XrdClLocalFileHandler.hh
XrdClLocalFileTask.cc XrdClLocalFileTask.hh
XrdClLog.cc XrdClLog.hh
XrdClUtils.cc XrdClUtils.hh
XrdClOptimizers.hh
XrdClConstants.hh
XrdClEnv.cc XrdClEnv.hh
XrdClDefaultEnv.cc XrdClDefaultEnv.hh
XrdClURL.cc XrdClURL.hh
XrdClStatus.cc XrdClStatus.hh
XrdClSocket.cc XrdClSocket.hh
XrdClTls.cc XrdClTls.hh
XrdClPoller.hh
XrdClPollerFactory.cc XrdClPollerFactory.hh
XrdClPollerBuiltIn.cc XrdClPollerBuiltIn.hh
XrdClPostMaster.cc XrdClPostMaster.hh
XrdClPostMasterInterfaces.hh
XrdClChannel.cc XrdClChannel.hh
XrdClStream.cc XrdClStream.hh
XrdClXRootDTransport.cc XrdClXRootDTransport.hh
XrdClInQueue.cc XrdClInQueue.hh
XrdClOutQueue.cc XrdClOutQueue.hh
XrdClTaskManager.cc XrdClTaskManager.hh
XrdClSIDManager.cc XrdClSIDManager.hh
XrdClFileSystem.cc XrdClFileSystem.hh
XrdClXRootDMsgHandler.cc XrdClXRootDMsgHandler.hh
XrdClBuffer.hh
XrdClMessage.hh
XrdClMessageUtils.cc XrdClMessageUtils.hh
XrdClXRootDResponses.cc XrdClXRootDResponses.hh
XrdClRequestSync.hh
XrdClFile.cc XrdClFile.hh
XrdClFileStateHandler.cc XrdClFileStateHandler.hh
XrdClCopyProcess.cc XrdClCopyProcess.hh
XrdClClassicCopyJob.cc XrdClClassicCopyJob.hh
XrdClThirdPartyCopyJob.cc XrdClThirdPartyCopyJob.hh
XrdClAsyncSocketHandler.cc XrdClAsyncSocketHandler.hh
XrdClAsyncTlsSocketHandler.cc XrdClAsyncTlsSocketHandler.hh
XrdClChannelHandlerList.cc XrdClChannelHandlerList.hh
XrdClForkHandler.cc XrdClForkHandler.hh
XrdClCheckSumManager.cc XrdClCheckSumManager.hh
XrdClTransportManager.cc XrdClTransportManager.hh
XrdClSyncQueue.hh
XrdClJobManager.cc XrdClJobManager.hh
XrdClResponseJob.hh
XrdClFileTimer.cc XrdClFileTimer.hh
XrdClUglyHacks.hh
XrdClPlugInInterface.hh
XrdClPlugInManager.cc XrdClPlugInManager.hh
XrdClPropertyList.hh
XrdClCopyJob.hh
XrdClFileSystemUtils.cc XrdClFileSystemUtils.hh
XrdClTPFallBackCopyJob.cc XrdClTPFallBackCopyJob.hh
XrdClMetalinkRedirector.cc XrdClMetalinkRedirector.hh
XrdClRedirectorRegistry.cc XrdClRedirectorRegistry.hh
XrdClZipArchiveReader.cc XrdClZipArchiveReader.hh
XrdClXCpCtx.cc XrdClXCpCtx.hh
XrdClXCpSrc.cc XrdClXCpSrc.hh
XrdClLocalFileHandler.cc XrdClLocalFileHandler.hh
XrdClLocalFileTask.cc XrdClLocalFileTask.hh
XrdClZipListHandler.cc XrdClZipListHandler.hh

${XrdClPipelineSources}
Expand All @@ -94,9 +96,11 @@ target_link_libraries(
XrdCl
XrdXml
XrdUtils
XrdTls
pthread
${EXTRA_LIBS}
${CMAKE_DL_LIBS})
ssl)

set_target_properties(
XrdCl
Expand Down
51 changes: 11 additions & 40 deletions src/XrdCl/XrdClAsyncSocketHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ namespace XrdCl
int status = pSocket->Send( msg->GetBufferAtCursor(), leftToBeWritten );
if( status <= 0 )
{
Status ret = ClassifyErrno( errno );
Status ret = Socket::ClassifyErrno( errno );
if( !ret.IsOK() )
toWrite->SetCursor( 0 );
return ret;
Expand Down Expand Up @@ -525,7 +525,7 @@ namespace XrdCl
int bytesWritten = pSocket->WriteV( iov, iovcnt );
if( bytesWritten <= 0 )
{
Status ret = ClassifyErrno( errno );
Status ret = Socket::ClassifyErrno( errno );
if( !ret.IsOK() )
toWrite->SetCursor( 0 );
return ret;
Expand Down Expand Up @@ -754,12 +754,20 @@ namespace XrdCl
if( st.code != suDone )
return;

HandleHandShake();
}

//------------------------------------------------------------------------
// Handle the handshake message
//------------------------------------------------------------------------
void AsyncSocketHandler::HandleHandShake()
{
//--------------------------------------------------------------------------
// OK, we have a new message, let's deal with it;
//--------------------------------------------------------------------------
pHandShakeData->in = pHSIncoming;
pHSIncoming = 0;
st = pTransport->HandShake( pHandShakeData, *pChannelData );
Status st = pTransport->HandShake( pHandShakeData, *pChannelData );

//--------------------------------------------------------------------------
// Deal with wait responses
Expand Down Expand Up @@ -1063,41 +1071,4 @@ namespace XrdCl
waitSeconds = rsp->body.wait.seconds;
return waitSeconds;
}

Status AsyncSocketHandler::ClassifyErrno( int error )
{
switch( errno )
{

case EAGAIN:
#if EAGAIN != EWOULDBLOCK
case EWOULDBLOCK:
#endif
{
//------------------------------------------------------------------
// Reading/writing operation would block! So we are done for now,
// but we will be back ;-)
//------------------------------------------------------------------
return Status( stOK, suRetry );
}
case ECONNRESET:
case EDESTADDRREQ:
case EMSGSIZE:
case ENOTCONN:
case ENOTSOCK:
{
//------------------------------------------------------------------
// Actual socket error error!
//------------------------------------------------------------------
return Status( stError, errSocketError, errno );
}
default:
{
//------------------------------------------------------------------
// Not a socket error
//------------------------------------------------------------------
return Status( stError, errInternal, errno );
}
}
}
}
30 changes: 12 additions & 18 deletions src/XrdCl/XrdClAsyncSocketHandler.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@
#define __XRD_CL_ASYNC_SOCKET_HANDLER_HH__

#include "XrdCl/XrdClSocket.hh"
#include "XrdCl/XrdClConstants.hh"
#include "XrdCl/XrdClDefaultEnv.hh"
#include "XrdCl/XrdClPoller.hh"
#include "XrdCl/XrdClPostMasterInterfaces.hh"
#include "XrdCl/XrdClTaskManager.hh"

#include <sys/types.h>
#include <sys/socket.h>
#include "XrdCl/XrdClXRootDResponses.hh"

namespace XrdCl
{
Expand Down Expand Up @@ -151,22 +148,22 @@ namespace XrdCl
return pLastActivity;
}

private:
protected:

//------------------------------------------------------------------------
// Connect returned
//------------------------------------------------------------------------
void OnConnectionReturn();
virtual void OnConnectionReturn();

//------------------------------------------------------------------------
// Got a write readiness event
//------------------------------------------------------------------------
void OnWrite();
virtual void OnWrite();

//------------------------------------------------------------------------
// Got a write readiness event while handshaking
//------------------------------------------------------------------------
void OnWriteWhileHandshaking();
virtual void OnWriteWhileHandshaking();


Status WriteMessageAndRaw( Message *toWrite, Message *&sign );
Expand All @@ -189,12 +186,17 @@ namespace XrdCl
//------------------------------------------------------------------------
// Got a read readiness event
//------------------------------------------------------------------------
void OnRead();
virtual void OnRead();

//------------------------------------------------------------------------
// Got a read readiness event while handshaking
//------------------------------------------------------------------------
void OnReadWhileHandshaking();
virtual void OnReadWhileHandshaking();

//------------------------------------------------------------------------
// Handle the handshake message
//------------------------------------------------------------------------
void HandleHandShake();

//------------------------------------------------------------------------
// Read a message
Expand Down Expand Up @@ -270,14 +272,6 @@ namespace XrdCl
//------------------------------------------------------------------------
inline kXR_int32 HandleWaitRsp( Message *rsp );

//------------------------------------------------------------------------
//! Classify errno while reading/writing
//!
//! Once we are at R5, change Transport interface and use:
//! Transport::ClassifyErrno
//------------------------------------------------------------------------
Status ClassifyErrno( int error );

//------------------------------------------------------------------------
// Data members
//------------------------------------------------------------------------
Expand Down

0 comments on commit 2cdd780

Please sign in to comment.