#include <icy/net/sslsocket.h>Inherits:
TCPSocket
SSL socket implementation.
| Return | Name | Description |
|---|---|---|
SSLSocket | Constructs an SSLSocket that acquires its context from SSLManager on first use. | |
SSLSocket | Constructs an SSLSocket with an explicit SSL context. | |
SSLSocket | Constructs an SSLSocket with an explicit context and a prior session for resumption. | |
void | connect virtual | Initialize the SSLSocket with the given SSLContext. |
void | connect virtual | Resolves host and initiates a secure connection. |
void | bind virtual | Binds the socket to address for server-side use. Throws std::logic_error if the context is not a server context. |
void | listen virtual | Starts listening for incoming connections. Throws std::logic_error if the context is not a server context. |
bool | shutdown virtual | Shuts down the connection by attempting an orderly SSL shutdown, then actually shutting down the TCP connection. |
void | close virtual | Closes the socket forcefully. |
ssize_t | send virtual | Encrypts and sends len bytes to the connected peer. |
ssize_t | sendOwned virtual | Sends an owned payload buffer to the connected peer. |
ssize_t | send virtual | Encrypts and sends len bytes, ignoring peerAddress (TCP is connected). |
ssize_t | sendOwned virtual | |
void | setHostname | Set the expected peer hostname for certificate verification and SNI. Must be called before connect() to enable hostname verification. |
void | useContext | Use the given SSL context for this socket. |
SSLContext::Ptr | context const | Returns the SSL context used for this socket. |
void | useSession | Sets the SSL session to use for the next connection. Setting a previously saved Session object is necessary to enable session caching. |
SSLSession::Ptr | currentSession | Returns the SSL session of the current connection, for reuse in a future connection (if session caching is enabled). |
bool | sessionWasReused | Returns true if a reused session was negotiated during the handshake. |
int | available const | Returns the number of bytes available from the SSL buffer for immediate reading. |
X509 * | peerCertificate const | Returns the peer's X.509 certificate, or nullptr if no certificate was presented. |
net::TransportType | transport virtual const | Returns the SSLTCP transport protocol identifier. |
void | acceptConnection virtual | Accepts a pending client connection, initializes the server-side SSL context on the new socket, and fires the AcceptConnection signal. |
void | onConnect virtual | Called when the TCP connection is established; starts reading and initiates the client-side SSL handshake. |
void | onRead virtual | Feeds raw encrypted bytes from the network into the SSL adapter. Called by the stream layer when ciphertext arrives from the peer. |
SSLSocket(uv::Loop * loop)Constructs an SSLSocket that acquires its context from SSLManager on first use.
loop Event loop to use; defaults to the default loop.SSLSocket(SSLContext::Ptr sslContext, uv::Loop * loop)Constructs an SSLSocket with an explicit SSL context.
sslContext The SSL context to use for this connection.
loop Event loop to use; defaults to the default loop.
SSLSocket(SSLContext::Ptr sslContext, SSLSession::Ptr session, uv::Loop * loop)Constructs an SSLSocket with an explicit context and a prior session for resumption.
sslContext The SSL context to use for this connection.
session A previously saved session to attempt resumption with.
loop Event loop to use; defaults to the default loop.
virtual
virtual void connect(const Address & peerAddress)Initialize the SSLSocket with the given SSLContext.
Initiates a secure connection to the peer at the given address.
The SSL handshake begins automatically once the TCP connection is established.
peerAddress The remote address to connect to.virtual
virtual void connect(std::string_view host, uint16_t port)Resolves host and initiates a secure connection.
Sets the hostname on the SSL adapter for SNI and certificate verification before resolving and connecting.
host Hostname or IP address string.
port Destination port.
virtual
virtual void bind(const net::Address & address, unsigned flags)Binds the socket to address for server-side use. Throws std::logic_error if the context is not a server context.
address Local address to bind to.
flags Optional bind flags (passed to uv_tcp_bind).
virtual
virtual void listen(int backlog)Starts listening for incoming connections. Throws std::logic_error if the context is not a server context.
backlog Maximum number of pending connections.virtual
virtual bool shutdown()Shuts down the connection by attempting an orderly SSL shutdown, then actually shutting down the TCP connection.
virtual
virtual void close()Closes the socket forcefully.
virtual
virtual ssize_t send(const char * data, size_t len, int flags)Encrypts and sends len bytes to the connected peer.
data Pointer to the plaintext payload.
len Number of bytes to send.
flags Reserved; currently unused.
Number of plaintext bytes accepted, or -1 on error.
virtual
virtual ssize_t sendOwned(Buffer && buffer, int flags)Sends an owned payload buffer to the connected peer.
virtual
virtual ssize_t send(const char * data, size_t len, const net::Address & peerAddress, int flags)Encrypts and sends len bytes, ignoring peerAddress (TCP is connected).
data Pointer to the plaintext payload.
len Number of bytes to send.
peerAddress Ignored for SSL/TCP; present for interface conformance.
flags Reserved; currently unused.
Number of plaintext bytes accepted, or -1 on error.
virtual
virtual ssize_t sendOwned(Buffer && buffer, const net::Address & peerAddress, int flags)void setHostname(std::string_view hostname)Set the expected peer hostname for certificate verification and SNI. Must be called before connect() to enable hostname verification.
void useContext(SSLContext::Ptr context)Use the given SSL context for this socket.
const
SSLContext::Ptr context() constReturns the SSL context used for this socket.
void useSession(SSLSession::Ptr session)Sets the SSL session to use for the next connection. Setting a previously saved Session object is necessary to enable session caching.
To remove the currently set session, a nullptr pointer can be given.
Must be called before connect() to be effective.
SSLSession::Ptr currentSession()Returns the SSL session of the current connection, for reuse in a future connection (if session caching is enabled).
If no connection is established, returns nullptr.
bool sessionWasReused()Returns true if a reused session was negotiated during the handshake.
const
int available() constReturns the number of bytes available from the SSL buffer for immediate reading.
const
X509 * peerCertificate() constReturns the peer's X.509 certificate, or nullptr if no certificate was presented.
virtual const
virtual net::TransportType transport() constReturns the SSLTCP transport protocol identifier.
virtual
virtual void acceptConnection()Accepts a pending client connection, initializes the server-side SSL context on the new socket, and fires the AcceptConnection signal.
virtual
virtual void onConnect()Called when the TCP connection is established; starts reading and initiates the client-side SSL handshake.
virtual
virtual void onRead(const char * data, size_t len)Feeds raw encrypted bytes from the network into the SSL adapter. Called by the stream layer when ciphertext arrives from the peer.
data Pointer to the encrypted bytes.
len Number of bytes received.
| Return | Name | Description |
|---|---|---|
net::SSLContext::Ptr | _sslContext | |
net::SSLSession::Ptr | _sslSession | |
net::SSLAdapter | _sslAdapter |
net::SSLContext::Ptr _sslContextnet::SSLSession::Ptr _sslSessionnet::SSLAdapter _sslAdapterstd::shared_ptr< SSLSocket > Ptr()std::vector< Ptr > Vec()