Fix TLS read/write dispatch on tls branch
TCPSocket inherits from both Socket and TLS, both declaring receiveData()
as unrelated sibling methods - only Socket::receiveData was virtual, so
TLS::receiveData (SSL_read) was never reached regardless of TLS config,
and even when reached its result was never forwarded to onDataReceived
(that call was commented out). Added an explicit TCPSocket::receiveData
override dispatching to TLS::receiveData or Socket::receiveData based on
tlsInfo, and completed TLS::receiveData to actually return/forward the
decrypted bytes.
Write path did not exist at all. Added Socket::sendData() as a new
virtual hook mirroring receiveData, routed Socket::writeSocket() through
it instead of a raw ::write(), added TLS::sendData() (SSL_write, same
error-handling style as the existing TLS methods), and TCPSocket::sendData()
dispatching the same way the read side does.
Also fixed: a queued write in writeSocket() was being popped off the fifo
as if sent even when shutDown was true and nothing was actually written;
removed a dead empty if(tlsInfo){} stub in onDataReceived, no longer
needed now dispatch happens one level up; replaced leftover debug
std::cout lines with proper Log() calls matching the rest of the file.
Verified via full local compile: all 20 .cpp files build clean, link
into libServerCore.a, and nm confirms the new/fixed symbols are correctly
defined in the right object files.
This commit is contained in:
1 parent
5feabd0fde
commit
701d03dcd9
6 files changed
+932
-851
No files matched your search
@@ -1,67 +1,68 @@
|
||||
#ifndef __TLS_h__
|
||||
#define __TLS_h__
|
||||
|
||||
#include "ZString.h"
|
||||
#include "TLSInfo.h"
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
namespace core {
|
||||
|
||||
///
|
||||
/// TLS
|
||||
///
|
||||
/// This object provides the support methods to handle TLS on the server core and
|
||||
/// session environment.
|
||||
///
|
||||
|
||||
class TLS {
|
||||
|
||||
public:
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
|
||||
TLS();
|
||||
|
||||
///
|
||||
/// Use this constructor when the SSL context needs to be created as when opening
|
||||
/// a server TCPSocket.
|
||||
///
|
||||
|
||||
TLS(TLSInfo *tlsInfo);
|
||||
|
||||
///
|
||||
/// Use this constructor on creation of a new TCPSocket that needs access to
|
||||
/// the generating server's SSL context.
|
||||
///
|
||||
|
||||
TLS(SSL_CTX *ctx);
|
||||
|
||||
///
|
||||
/// The destructor for this object.
|
||||
///
|
||||
|
||||
~TLS();
|
||||
|
||||
void createContext(TLSInfo *tlsInfo);
|
||||
|
||||
SSL_CTX *ctx;
|
||||
|
||||
protected:
|
||||
void receiveData(coreutils::ZString &buffer);
|
||||
void registerSocket(int fd);
|
||||
void acceptSocket();
|
||||
|
||||
private:
|
||||
char *sip_cacert = (char *)"../testkeys/certs/pbxca.crt";
|
||||
char *sip_cert = (char *)"../testkeys/certs/pbxserver.crt";
|
||||
char *sip_key = (char *)"../testkeys/certs/pbxserver.key";
|
||||
bool initialized = false;
|
||||
SSL *ssl;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifndef __TLS_h__
|
||||
#define __TLS_h__
|
||||
|
||||
#include "ZString.h"
|
||||
#include "TLSInfo.h"
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
namespace core {
|
||||
|
||||
///
|
||||
/// TLS
|
||||
///
|
||||
/// This object provides the support methods to handle TLS on the server core and
|
||||
/// session environment.
|
||||
///
|
||||
|
||||
class TLS {
|
||||
|
||||
public:
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
|
||||
TLS();
|
||||
|
||||
///
|
||||
/// Use this constructor when the SSL context needs to be created as when opening
|
||||
/// a server TCPSocket.
|
||||
///
|
||||
|
||||
TLS(TLSInfo *tlsInfo);
|
||||
|
||||
///
|
||||
/// Use this constructor on creation of a new TCPSocket that needs access to
|
||||
/// the generating server's SSL context.
|
||||
///
|
||||
|
||||
TLS(SSL_CTX *ctx);
|
||||
|
||||
///
|
||||
/// The destructor for this object.
|
||||
///
|
||||
|
||||
~TLS();
|
||||
|
||||
void createContext(TLSInfo *tlsInfo);
|
||||
|
||||
SSL_CTX *ctx;
|
||||
|
||||
protected:
|
||||
int receiveData(coreutils::ZString &buffer);
|
||||
int sendData(const char *data, int length);
|
||||
void registerSocket(int fd);
|
||||
void acceptSocket();
|
||||
|
||||
private:
|
||||
char *sip_cacert = (char *)"../testkeys/certs/pbxca.crt";
|
||||
char *sip_cert = (char *)"../testkeys/certs/pbxserver.crt";
|
||||
char *sip_key = (char *)"../testkeys/certs/pbxserver.key";
|
||||
bool initialized = false;
|
||||
SSL *ssl;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user