12 #include "../OSSupport/Network.h"
36 bool Send(
const void * a_Data,
size_t a_NumBytes);
42 int Receive(
void * a_Data,
size_t a_MaxBytes);
56 void SetSslConfig(std::shared_ptr<const cSslConfig> a_Config);
113 virtual int ReceiveEncrypted(
unsigned char * a_Buffer,
size_t a_NumBytes)
override;
114 virtual int SendEncrypted(
const unsigned char * a_Buffer,
size_t a_NumBytes)
override;
std::shared_ptr< cTCPLink > cTCPLinkPtr
cCallbackSslContext m_Ssl
The SSL context used for the socket.
const AString & GetLastErrorText(void) const
Returns the text of the last error that has occurred in this instance.
void Disconnect(void)
Disconnects the connection gracefully, if possible.
bool Connect(const AString &a_ServerName, UInt16 a_Port)
Connects to the specified server and performs SSL handshake.
cTCPLinkPtr m_Socket
The underlying socket to the SSL server.
void SetSslConfig(std::shared_ptr< const cSslConfig > a_Config)
Set the config to be used by the SSL context.
void OnConnected(void)
Called when the connection is established successfully.
AString m_ServerName
The hostname to which the socket is connecting (stored for error reporting).
cBlockingSslClientSocket(void)
int Receive(void *a_Data, size_t a_MaxBytes)
Receives data from the connection.
virtual int ReceiveEncrypted(unsigned char *a_Buffer, size_t a_NumBytes) override
Called when mbedTLS wants to read encrypted data from the SSL peer.
virtual int SendEncrypted(const unsigned char *a_Buffer, size_t a_NumBytes) override
Called when mbedTLS wants to write encrypted data to the SSL peer.
void SetExpectedPeerName(AString a_ExpectedPeerName)
Sets the Expected peer name.
std::atomic< bool > m_IsConnected
Set to true if the connection established successfully.
void OnConnectError(const AString &a_ErrorMsg)
Called when an error occurs while connecting the socket.
std::shared_ptr< const cSslConfig > m_Config
The configuration to be used by the SSL context.
cEvent m_Event
The object used to signal state changes in the socket (the cause of the blocking).
bool Send(const void *a_Data, size_t a_NumBytes)
Sends the specified data over the connection.
AString m_ExpectedPeerName
The expected SSL peer's name, if we are to verify the cert strictly.
cCriticalSection m_CSIncomingData
Protects m_IncomingData against multithreaded access.
virtual ~cBlockingSslClientSocket(void) override
AString m_IncomingData
Buffer for the data incoming on the network socket.
void OnReceivedData(const char *a_Data, size_t a_Size)
Called when there's incoming data from the socket.
void OnDisconnected(void)
Called when the link is disconnected, either gracefully or by an error.
void SetLink(cTCPLinkPtr a_Link)
Called when the link for the connection is created.
AString m_LastErrorText
Text of the last error that has occurred.
Interface used as a data sink for the SSL peer data.