#include <icy/net/ssladapter.h>Manages the OpenSSL context and BIO buffers for an SSL socket connection.
| Return | Name | Description |
|---|---|---|
SSLAdapter | Constructs the SSLAdapter and associates it with the given socket. The socket pointer must remain valid for the lifetime of this adapter. | |
SSLAdapter | Deleted constructor. | |
SSLAdapter | Deleted constructor. | |
void | initClient | Initializes the SSL context as a client. |
void | initServer | Initializes the SSL context as a server. |
bool | initialized const | Returns true when SSL context has been initialized. |
bool | ready const | Returns true when the handshake is complete. |
void | handshake | Start/continue the SSL handshake process. |
int | available const | Returns the number of bytes available in the SSL buffer for immediate reading. |
void | shutdown | Issues an orderly SSL shutdown. |
void | flush | Flushes the SSL read/write buffers. |
void | setHostname | Set the expected peer hostname for certificate verification. Must be called before initClient() to enable hostname verification. |
void | addIncomingData | Feeds encrypted data received from the network into the SSL read BIO. Triggers a flush, which drives the handshake or decrypts and delivers plaintext to the socket via onRecv(). |
void | addOutgoingData | Queues plaintext data for encryption and transmission. |
void | addOutgoingData | Queues plaintext data for encryption and transmission. |
void | addOutgoingData | Moves plaintext data into the pending write buffer when possible. |
SSLAdapter(net::SSLSocket * socket)Constructs the SSLAdapter and associates it with the given socket. The socket pointer must remain valid for the lifetime of this adapter.
socket The owning SSLSocket that sends and receives raw data.SSLAdapter(const SSLAdapter &) = deleteDeleted constructor.
SSLAdapter(SSLAdapter &&) = deleteDeleted constructor.
void initClient()Initializes the SSL context as a client.
void initServer()Initializes the SSL context as a server.
const
bool initialized() constReturns true when SSL context has been initialized.
const
bool ready() constReturns true when the handshake is complete.
void handshake()Start/continue the SSL handshake process.
const
int available() constReturns the number of bytes available in the SSL buffer for immediate reading.
void shutdown()Issues an orderly SSL shutdown.
void flush()Flushes the SSL read/write buffers.
void setHostname(std::string_view hostname)Set the expected peer hostname for certificate verification. Must be called before initClient() to enable hostname verification.
void addIncomingData(const char * data, size_t len)Feeds encrypted data received from the network into the SSL read BIO. Triggers a flush, which drives the handshake or decrypts and delivers plaintext to the socket via onRecv().
data Pointer to the encrypted bytes.
len Number of bytes to feed.
void addOutgoingData(std::string_view data)Queues plaintext data for encryption and transmission.
data String view of the plaintext payload.void addOutgoingData(const char * data, size_t len)Queues plaintext data for encryption and transmission.
data Pointer to the plaintext bytes.
len Number of bytes to queue.
void addOutgoingData(Buffer && data)Moves plaintext data into the pending write buffer when possible.
| Return | Name | Description |
|---|---|---|
net::SSLSocket * | _socket | |
SSL * | _ssl | |
BIO * | _readBIO | The incoming buffer we write encrypted SSL data into. |
BIO * | _writeBIO | The outgoing buffer we write to the socket. |
std::vector< char > | _bufferOut | The outgoing payload to be encrypted and sent. |
std::string | _hostname | Expected peer hostname for verification. |
net::SSLSocket * _socketSSL * _sslBIO * _readBIOThe incoming buffer we write encrypted SSL data into.
BIO * _writeBIOThe outgoing buffer we write to the socket.
std::vector< char > _bufferOutThe outgoing payload to be encrypted and sent.
std::string _hostnameExpected peer hostname for verification.
| Return | Name | Description |
|---|---|---|
void | handleError | |
void | flushReadBIO | |
void | flushWriteBIO |
void handleError(int rc)void flushReadBIO()void flushWriteBIO()