boost::corosio::tls_stream::handshake
Perform the TLS handshake asynchronously.
Synopsis
auto
handshake(handshake_type type);
Description
This function initiates the TLS handshake process. For client connections, this sends the ClientHello and processes the server's response. For server connections, this waits for the ClientHello and sends the server's response.
The operation supports cancellation via std::stop_token through the affine awaitable protocol. If the associated stop token is triggered, the operation completes immediately with errc::operation_canceled.
Example
// Client handshake with error code
auto [ec] = co_await secure.handshake(tls_stream::client);
if(ec) { ... }
// Or with exceptions
(co_await secure.handshake(tls_stream::client)).value();
Return Value
An awaitable that completes with io_result<>. Returns success on successful handshake, or an error code on failure including: ‐ SSL/TLS errors from the underlying library ‐ operation_canceled: Cancelled via stop_token
Parameters
| Name | Description |
|---|---|
type |
The type of handshaking to perform (client or server). |
Created with MrDocs