2020-04-14 15:02:18 -04:00
|
|
|
/***********************************************************************************************************************************
|
|
|
|
TLS Session
|
|
|
|
***********************************************************************************************************************************/
|
|
|
|
#include "build.auto.h"
|
|
|
|
|
2020-04-20 11:08:58 -04:00
|
|
|
#include <openssl/err.h>
|
|
|
|
|
2020-04-14 15:02:18 -04:00
|
|
|
#include "common/crypto/common.h"
|
|
|
|
#include "common/debug.h"
|
|
|
|
#include "common/io/io.h"
|
2021-04-13 14:37:02 -04:00
|
|
|
#include "common/io/read.h"
|
|
|
|
#include "common/io/session.h"
|
2020-08-08 10:39:39 -04:00
|
|
|
#include "common/io/tls/client.h"
|
|
|
|
#include "common/io/tls/session.h"
|
2021-04-13 14:37:02 -04:00
|
|
|
#include "common/io/write.h"
|
2020-04-14 15:02:18 -04:00
|
|
|
#include "common/log.h"
|
|
|
|
#include "common/type/object.h"
|
|
|
|
|
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Object type
|
|
|
|
***********************************************************************************************************************************/
|
2020-08-08 10:39:39 -04:00
|
|
|
typedef struct TlsSession
|
2020-04-14 15:02:18 -04:00
|
|
|
{
|
2020-08-10 16:03:38 -04:00
|
|
|
IoSession *ioSession; // Io session
|
|
|
|
SSL *session; // TLS session on the file descriptor
|
2020-04-14 15:02:18 -04:00
|
|
|
TimeMSec timeout; // Timeout for any i/o operation (connect, read, etc.)
|
2020-08-10 16:03:38 -04:00
|
|
|
bool shutdownOnClose; // Shutdown the TLS connection when closing the session
|
2020-04-14 15:02:18 -04:00
|
|
|
|
|
|
|
IoRead *read; // Read interface
|
|
|
|
IoWrite *write; // Write interface
|
2020-08-08 10:39:39 -04:00
|
|
|
} TlsSession;
|
2020-04-14 15:02:18 -04:00
|
|
|
|
2020-08-08 10:39:39 -04:00
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Macros for function logging
|
|
|
|
***********************************************************************************************************************************/
|
|
|
|
static String *
|
|
|
|
tlsSessionToLog(const THIS_VOID)
|
|
|
|
{
|
|
|
|
THIS(const TlsSession);
|
2020-04-14 15:02:18 -04:00
|
|
|
|
2020-08-08 10:39:39 -04:00
|
|
|
return strNewFmt(
|
2020-08-10 16:03:38 -04:00
|
|
|
"{ioSession: %s, timeout: %" PRIu64", shutdownOnClose: %s}",
|
2021-09-01 11:10:35 -04:00
|
|
|
objMemContextFreeing(this) ? NULL_Z : strZ(ioSessionToLog(this->ioSession)), this->timeout,
|
2020-08-10 16:03:38 -04:00
|
|
|
cvtBoolToConstZ(this->shutdownOnClose));
|
2020-08-08 10:39:39 -04:00
|
|
|
}
|
2020-04-14 15:02:18 -04:00
|
|
|
|
2020-08-08 10:39:39 -04:00
|
|
|
#define FUNCTION_LOG_TLS_SESSION_TYPE \
|
|
|
|
TlsSession *
|
|
|
|
#define FUNCTION_LOG_TLS_SESSION_FORMAT(value, buffer, bufferSize) \
|
|
|
|
FUNCTION_LOG_STRING_OBJECT_FORMAT(value, tlsSessionToLog, buffer, bufferSize)
|
2020-04-14 15:02:18 -04:00
|
|
|
|
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Free connection
|
|
|
|
***********************************************************************************************************************************/
|
2021-04-07 16:27:55 -04:00
|
|
|
static void
|
|
|
|
tlsSessionFreeResource(THIS_VOID)
|
2020-04-14 15:02:18 -04:00
|
|
|
{
|
2021-04-07 16:27:55 -04:00
|
|
|
THIS(TlsSession);
|
|
|
|
|
|
|
|
FUNCTION_LOG_BEGIN(logLevelTrace);
|
|
|
|
FUNCTION_LOG_PARAM(TLS_SESSION, this);
|
|
|
|
FUNCTION_LOG_END();
|
|
|
|
|
|
|
|
ASSERT(this != NULL);
|
|
|
|
|
2020-04-14 15:02:18 -04:00
|
|
|
SSL_free(this->session);
|
2021-04-07 16:27:55 -04:00
|
|
|
|
|
|
|
FUNCTION_LOG_RETURN_VOID();
|
2020-04-14 15:02:18 -04:00
|
|
|
}
|
|
|
|
|
2020-04-14 15:22:49 -04:00
|
|
|
/**********************************************************************************************************************************/
|
2020-08-08 10:39:39 -04:00
|
|
|
static void
|
|
|
|
tlsSessionClose(THIS_VOID)
|
2020-04-14 15:02:18 -04:00
|
|
|
{
|
2020-08-08 10:39:39 -04:00
|
|
|
THIS(TlsSession);
|
|
|
|
|
2020-04-14 15:02:18 -04:00
|
|
|
FUNCTION_LOG_BEGIN(logLevelTrace);
|
|
|
|
FUNCTION_LOG_PARAM(TLS_SESSION, this);
|
|
|
|
FUNCTION_LOG_END();
|
|
|
|
|
|
|
|
ASSERT(this != NULL);
|
|
|
|
|
|
|
|
// If not already closed
|
|
|
|
if (this->session != NULL)
|
|
|
|
{
|
2020-04-14 15:22:49 -04:00
|
|
|
// Shutdown on request
|
2020-08-08 10:39:39 -04:00
|
|
|
if (this->shutdownOnClose)
|
2020-04-14 15:22:49 -04:00
|
|
|
SSL_shutdown(this->session);
|
|
|
|
|
2020-08-10 16:03:38 -04:00
|
|
|
// Close the io session
|
|
|
|
ioSessionClose(this->ioSession);
|
2020-04-14 15:02:18 -04:00
|
|
|
|
|
|
|
// Free the TLS session
|
2021-09-01 11:10:35 -04:00
|
|
|
memContextCallbackClear(objMemContext(this));
|
2020-04-14 15:02:18 -04:00
|
|
|
tlsSessionFreeResource(this);
|
|
|
|
this->session = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
FUNCTION_LOG_RETURN_VOID();
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************************************************************************
|
2020-04-16 16:05:44 -04:00
|
|
|
Process result from SSL_read(), SSL_write(), SSL_connect(), and SSL_accept().
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
0 if the function should be tried again with the same parameters
|
|
|
|
-1 if the connection was closed gracefully
|
|
|
|
> 0 with the read/write size if SSL_read()/SSL_write() was called
|
2020-04-14 15:02:18 -04:00
|
|
|
***********************************************************************************************************************************/
|
2020-04-16 16:05:44 -04:00
|
|
|
// Helper to process error conditions
|
|
|
|
static int
|
2020-08-04 15:15:24 -04:00
|
|
|
tlsSessionResultProcess(TlsSession *this, int errorTls, long unsigned int errorTlsDetail, int errorSys, bool closeOk)
|
2020-04-14 15:02:18 -04:00
|
|
|
{
|
|
|
|
FUNCTION_LOG_BEGIN(logLevelTrace);
|
|
|
|
FUNCTION_LOG_PARAM(TLS_SESSION, this);
|
2020-04-16 16:05:44 -04:00
|
|
|
FUNCTION_LOG_PARAM(INT, errorTls);
|
2020-08-04 15:15:24 -04:00
|
|
|
FUNCTION_LOG_PARAM(UINT64, errorTlsDetail);
|
2020-04-16 16:05:44 -04:00
|
|
|
FUNCTION_LOG_PARAM(INT, errorSys);
|
|
|
|
FUNCTION_LOG_PARAM(BOOL, closeOk);
|
2020-04-14 15:02:18 -04:00
|
|
|
FUNCTION_LOG_END();
|
|
|
|
|
2020-04-16 16:05:44 -04:00
|
|
|
ASSERT(this != NULL);
|
|
|
|
ASSERT(this->session != NULL);
|
|
|
|
|
|
|
|
int result = -1;
|
2020-04-14 15:02:18 -04:00
|
|
|
|
2020-04-16 16:05:44 -04:00
|
|
|
switch (errorTls)
|
2020-04-14 15:02:18 -04:00
|
|
|
{
|
|
|
|
// The connection was closed
|
|
|
|
case SSL_ERROR_ZERO_RETURN:
|
|
|
|
{
|
2020-04-16 16:05:44 -04:00
|
|
|
if (!closeOk)
|
|
|
|
THROW(ProtocolError, "unexpected TLS eof");
|
|
|
|
|
2020-08-08 10:39:39 -04:00
|
|
|
this->shutdownOnClose = false;
|
|
|
|
tlsSessionClose(this);
|
2020-04-14 15:02:18 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-04-16 16:05:44 -04:00
|
|
|
// Try again after waiting for read ready
|
2020-04-14 15:02:18 -04:00
|
|
|
case SSL_ERROR_WANT_READ:
|
2020-08-10 16:03:38 -04:00
|
|
|
ioReadReadyP(ioSessionIoRead(this->ioSession), .error = true);
|
2020-04-16 16:05:44 -04:00
|
|
|
result = 0;
|
2020-04-14 15:02:18 -04:00
|
|
|
break;
|
|
|
|
|
2020-04-16 16:05:44 -04:00
|
|
|
// Try again after waiting for write ready
|
|
|
|
case SSL_ERROR_WANT_WRITE:
|
2020-08-10 16:03:38 -04:00
|
|
|
ioWriteReadyP(ioSessionIoWrite(this->ioSession), .error = true);
|
2020-04-16 16:05:44 -04:00
|
|
|
result = 0;
|
|
|
|
break;
|
2020-04-14 15:02:18 -04:00
|
|
|
|
2020-04-16 16:05:44 -04:00
|
|
|
// A syscall failed (this usually indicates unexpected eof)
|
|
|
|
case SSL_ERROR_SYSCALL:
|
|
|
|
THROW_SYS_ERROR_CODE(errorSys, KernelError, "TLS syscall error");
|
|
|
|
|
|
|
|
// Any other error that we cannot handle
|
2020-04-14 15:02:18 -04:00
|
|
|
default:
|
2020-08-04 15:15:24 -04:00
|
|
|
{
|
|
|
|
// Get detailed error message when available
|
|
|
|
const char *errorTlsDetailMessage = ERR_reason_error_string(errorTlsDetail);
|
|
|
|
|
|
|
|
THROW_FMT(
|
|
|
|
ServiceError, "TLS error [%d:%lu] %s", errorTls, errorTlsDetail,
|
|
|
|
errorTlsDetailMessage == NULL ? "no details available" : errorTlsDetailMessage);
|
|
|
|
}
|
2020-04-16 16:05:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
FUNCTION_LOG_RETURN(INT, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tlsSessionResult(TlsSession *this, int result, bool closeOk)
|
|
|
|
{
|
|
|
|
FUNCTION_LOG_BEGIN(logLevelTrace);
|
|
|
|
FUNCTION_LOG_PARAM(TLS_SESSION, this);
|
|
|
|
FUNCTION_LOG_PARAM(INT, result);
|
|
|
|
FUNCTION_LOG_PARAM(BOOL, closeOk);
|
|
|
|
FUNCTION_LOG_END();
|
|
|
|
|
|
|
|
ASSERT(this != NULL);
|
|
|
|
ASSERT(this->session != NULL);
|
|
|
|
|
|
|
|
// Process errors
|
|
|
|
if (result <= 0)
|
|
|
|
{
|
|
|
|
// Get TLS error and store errno in case of syscall error
|
|
|
|
int errorTls = SSL_get_error(this->session, result);
|
2020-08-04 15:15:24 -04:00
|
|
|
long unsigned int errorTlsDetail = ERR_get_error();
|
2020-04-16 16:05:44 -04:00
|
|
|
int errorSys = errno;
|
|
|
|
|
2020-08-04 15:15:24 -04:00
|
|
|
result = tlsSessionResultProcess(this, errorTls, errorTlsDetail, errorSys, closeOk);
|
2020-04-14 15:02:18 -04:00
|
|
|
}
|
|
|
|
|
2020-04-16 16:05:44 -04:00
|
|
|
FUNCTION_LOG_RETURN(INT, result);
|
2020-04-14 15:02:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Read from the TLS session
|
|
|
|
***********************************************************************************************************************************/
|
|
|
|
static size_t
|
|
|
|
tlsSessionRead(THIS_VOID, Buffer *buffer, bool block)
|
|
|
|
{
|
|
|
|
THIS(TlsSession);
|
|
|
|
|
|
|
|
FUNCTION_LOG_BEGIN(logLevelTrace);
|
|
|
|
FUNCTION_LOG_PARAM(TLS_SESSION, this);
|
|
|
|
FUNCTION_LOG_PARAM(BUFFER, buffer);
|
|
|
|
FUNCTION_LOG_PARAM(BOOL, block);
|
|
|
|
FUNCTION_LOG_END();
|
|
|
|
|
|
|
|
ASSERT(this != NULL);
|
|
|
|
ASSERT(this->session != NULL);
|
|
|
|
ASSERT(buffer != NULL);
|
|
|
|
ASSERT(!bufFull(buffer));
|
|
|
|
|
2020-04-16 16:05:44 -04:00
|
|
|
int result = 0;
|
2020-04-14 15:02:18 -04:00
|
|
|
|
|
|
|
// If blocking read keep reading until buffer is full
|
|
|
|
do
|
|
|
|
{
|
2020-08-10 16:03:38 -04:00
|
|
|
// If no TLS data pending then check the io to reduce blocking
|
2020-04-14 15:02:18 -04:00
|
|
|
if (!SSL_pending(this->session))
|
2020-08-10 16:03:38 -04:00
|
|
|
ioReadReadyP(ioSessionIoRead(this->ioSession), .error = true);
|
2020-04-14 15:02:18 -04:00
|
|
|
|
2020-04-20 11:08:58 -04:00
|
|
|
// Read and handle errors. The error queue must be cleared before this operation.
|
|
|
|
ERR_clear_error();
|
|
|
|
|
2020-04-16 16:05:44 -04:00
|
|
|
result = tlsSessionResult(this, SSL_read(this->session, bufRemainsPtr(buffer), (int)bufRemains(buffer)), true);
|
2020-04-14 15:02:18 -04:00
|
|
|
|
|
|
|
// Update amount of buffer used
|
2020-04-16 16:05:44 -04:00
|
|
|
if (result > 0)
|
|
|
|
{
|
2020-04-14 15:02:18 -04:00
|
|
|
bufUsedInc(buffer, (size_t)result);
|
2020-04-16 16:05:44 -04:00
|
|
|
}
|
|
|
|
// If the connection was closed then we are at eof. It is up to the layer above TLS to decide if this is an error.
|
|
|
|
else if (result == -1)
|
|
|
|
break;
|
2020-04-14 15:02:18 -04:00
|
|
|
}
|
|
|
|
while (block && bufRemains(buffer) > 0);
|
|
|
|
|
|
|
|
FUNCTION_LOG_RETURN(SIZE, (size_t)result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************************************************************************
|
2020-04-16 16:05:44 -04:00
|
|
|
Write to the TLS session
|
2020-04-14 15:02:18 -04:00
|
|
|
***********************************************************************************************************************************/
|
|
|
|
static void
|
|
|
|
tlsSessionWrite(THIS_VOID, const Buffer *buffer)
|
|
|
|
{
|
|
|
|
THIS(TlsSession);
|
|
|
|
|
|
|
|
FUNCTION_LOG_BEGIN(logLevelTrace);
|
|
|
|
FUNCTION_LOG_PARAM(TLS_SESSION, this);
|
|
|
|
FUNCTION_LOG_PARAM(BUFFER, buffer);
|
|
|
|
FUNCTION_LOG_END();
|
|
|
|
|
|
|
|
ASSERT(this != NULL);
|
|
|
|
ASSERT(this->session != NULL);
|
|
|
|
ASSERT(buffer != NULL);
|
|
|
|
|
|
|
|
int result = 0;
|
|
|
|
|
2020-04-16 16:05:44 -04:00
|
|
|
while (result == 0)
|
2020-04-14 15:02:18 -04:00
|
|
|
{
|
2020-04-20 11:08:58 -04:00
|
|
|
// Write and handle errors. The error queue must be cleared before this operation.
|
|
|
|
ERR_clear_error();
|
|
|
|
|
2020-04-16 16:05:44 -04:00
|
|
|
result = tlsSessionResult(this, SSL_write(this->session, bufPtrConst(buffer), (int)bufUsed(buffer)), false);
|
|
|
|
|
|
|
|
// Either a retry or all data was written
|
|
|
|
CHECK(result == 0 || (size_t)result == bufUsed(buffer));
|
2020-04-14 15:02:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
FUNCTION_LOG_RETURN_VOID();
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Has session been closed by the server?
|
|
|
|
***********************************************************************************************************************************/
|
|
|
|
static bool
|
|
|
|
tlsSessionEof(THIS_VOID)
|
|
|
|
{
|
|
|
|
THIS(TlsSession);
|
|
|
|
|
|
|
|
FUNCTION_LOG_BEGIN(logLevelTrace);
|
|
|
|
FUNCTION_LOG_PARAM(TLS_SESSION, this);
|
|
|
|
FUNCTION_LOG_END();
|
|
|
|
|
|
|
|
ASSERT(this != NULL);
|
|
|
|
|
|
|
|
FUNCTION_LOG_RETURN(BOOL, this->session == NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************************************************************************/
|
2020-08-08 10:39:39 -04:00
|
|
|
static IoRead *
|
|
|
|
tlsSessionIoRead(THIS_VOID)
|
|
|
|
{
|
|
|
|
THIS(TlsSession);
|
|
|
|
|
|
|
|
FUNCTION_TEST_BEGIN();
|
|
|
|
FUNCTION_TEST_PARAM(TLS_SESSION, this);
|
|
|
|
FUNCTION_TEST_END();
|
|
|
|
|
|
|
|
ASSERT(this != NULL);
|
|
|
|
|
|
|
|
FUNCTION_TEST_RETURN(this->read);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************************************************************************/
|
|
|
|
static IoWrite *
|
|
|
|
tlsSessionIoWrite(THIS_VOID)
|
|
|
|
{
|
|
|
|
THIS(TlsSession);
|
|
|
|
|
|
|
|
FUNCTION_TEST_BEGIN();
|
|
|
|
FUNCTION_TEST_PARAM(TLS_SESSION, this);
|
|
|
|
FUNCTION_TEST_END();
|
|
|
|
|
|
|
|
ASSERT(this != NULL);
|
|
|
|
|
|
|
|
FUNCTION_TEST_RETURN(this->write);
|
|
|
|
}
|
|
|
|
|
2020-08-10 16:03:38 -04:00
|
|
|
/**********************************************************************************************************************************/
|
|
|
|
static IoSessionRole
|
|
|
|
tlsSessionRole(const THIS_VOID)
|
|
|
|
{
|
|
|
|
THIS(const TlsSession);
|
|
|
|
|
|
|
|
FUNCTION_TEST_BEGIN();
|
|
|
|
FUNCTION_TEST_PARAM(TLS_SESSION, this);
|
|
|
|
FUNCTION_TEST_END();
|
|
|
|
|
|
|
|
ASSERT(this != NULL);
|
|
|
|
|
|
|
|
FUNCTION_TEST_RETURN(ioSessionRole(this->ioSession));
|
|
|
|
}
|
|
|
|
|
2020-08-08 10:39:39 -04:00
|
|
|
/**********************************************************************************************************************************/
|
|
|
|
static const IoSessionInterface tlsSessionInterface =
|
|
|
|
{
|
2021-04-28 12:37:22 -04:00
|
|
|
.type = IO_CLIENT_TLS_TYPE,
|
2020-08-08 10:39:39 -04:00
|
|
|
.close = tlsSessionClose,
|
|
|
|
.ioRead = tlsSessionIoRead,
|
|
|
|
.ioWrite = tlsSessionIoWrite,
|
2020-08-10 16:03:38 -04:00
|
|
|
.role = tlsSessionRole,
|
2020-08-08 10:39:39 -04:00
|
|
|
.toLog = tlsSessionToLog,
|
|
|
|
};
|
|
|
|
|
|
|
|
IoSession *
|
2020-08-10 16:03:38 -04:00
|
|
|
tlsSessionNew(SSL *session, IoSession *ioSession, TimeMSec timeout)
|
2020-04-14 15:02:18 -04:00
|
|
|
{
|
|
|
|
FUNCTION_LOG_BEGIN(logLevelDebug)
|
|
|
|
FUNCTION_LOG_PARAM_P(VOID, session);
|
2020-08-10 16:03:38 -04:00
|
|
|
FUNCTION_LOG_PARAM(IO_SESSION, ioSession);
|
2020-04-14 15:02:18 -04:00
|
|
|
FUNCTION_LOG_PARAM(TIME_MSEC, timeout);
|
|
|
|
FUNCTION_LOG_END();
|
|
|
|
|
|
|
|
ASSERT(session != NULL);
|
2020-08-10 16:03:38 -04:00
|
|
|
ASSERT(ioSession != NULL);
|
2020-04-14 15:02:18 -04:00
|
|
|
|
2020-08-08 10:39:39 -04:00
|
|
|
IoSession *this = NULL;
|
2020-04-14 15:02:18 -04:00
|
|
|
|
2021-09-01 11:10:35 -04:00
|
|
|
OBJ_NEW_BEGIN(TlsSession)
|
2020-04-14 15:02:18 -04:00
|
|
|
{
|
2021-09-01 11:10:35 -04:00
|
|
|
TlsSession *driver = OBJ_NEW_ALLOC();
|
2020-04-14 15:02:18 -04:00
|
|
|
|
2020-08-08 10:39:39 -04:00
|
|
|
*driver = (TlsSession)
|
2020-04-14 15:02:18 -04:00
|
|
|
{
|
|
|
|
.session = session,
|
2020-08-10 16:03:38 -04:00
|
|
|
.ioSession = ioSessionMove(ioSession, MEM_CONTEXT_NEW()),
|
2020-04-14 15:02:18 -04:00
|
|
|
.timeout = timeout,
|
2020-08-08 10:39:39 -04:00
|
|
|
.shutdownOnClose = true,
|
2020-04-14 15:02:18 -04:00
|
|
|
};
|
|
|
|
|
2020-04-14 15:22:49 -04:00
|
|
|
// Ensure session is freed
|
2021-09-01 11:10:35 -04:00
|
|
|
memContextCallbackSet(objMemContext(driver), tlsSessionFreeResource, driver);
|
2020-04-14 15:22:49 -04:00
|
|
|
|
2020-08-10 16:03:38 -04:00
|
|
|
// Assign file descriptor to TLS session
|
|
|
|
cryptoError(SSL_set_fd(driver->session, ioSessionFd(driver->ioSession)) != 1, "unable to add fd to TLS session");
|
2020-04-14 15:02:18 -04:00
|
|
|
|
2020-04-20 11:08:58 -04:00
|
|
|
// Negotiate TLS session. The error queue must be cleared before this operation.
|
2020-04-16 16:05:44 -04:00
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
while (result == 0)
|
|
|
|
{
|
2020-04-20 11:08:58 -04:00
|
|
|
ERR_clear_error();
|
|
|
|
|
2020-08-10 16:03:38 -04:00
|
|
|
if (ioSessionRole(driver->ioSession) == ioSessionRoleClient)
|
2020-08-08 10:39:39 -04:00
|
|
|
result = tlsSessionResult(driver, SSL_connect(driver->session), false);
|
2020-04-16 16:05:44 -04:00
|
|
|
else
|
2020-08-08 10:39:39 -04:00
|
|
|
result = tlsSessionResult(driver, SSL_accept(driver->session), false);
|
2020-04-16 16:05:44 -04:00
|
|
|
}
|
2020-04-14 15:02:18 -04:00
|
|
|
|
|
|
|
// Create read and write interfaces
|
2020-08-08 10:39:39 -04:00
|
|
|
driver->write = ioWriteNewP(driver, .write = tlsSessionWrite);
|
|
|
|
ioWriteOpen(driver->write);
|
|
|
|
driver->read = ioReadNewP(driver, .block = true, .eof = tlsSessionEof, .read = tlsSessionRead);
|
|
|
|
ioReadOpen(driver->read);
|
|
|
|
|
|
|
|
// Create session interface
|
|
|
|
this = ioSessionNew(driver, &tlsSessionInterface);
|
2020-04-14 15:02:18 -04:00
|
|
|
}
|
2021-09-01 11:10:35 -04:00
|
|
|
OBJ_NEW_END();
|
2020-04-14 15:02:18 -04:00
|
|
|
|
2020-08-08 10:39:39 -04:00
|
|
|
FUNCTION_LOG_RETURN(IO_SESSION, this);
|
2020-04-14 15:02:18 -04:00
|
|
|
}
|