boost::corosio::openssl_stream
A TLS stream using OpenSSL.
Synopsis
Declared in <boost/corosio/openssl_stream.hpp>
class openssl_stream final
: public tls_stream
Description
This class wraps an underlying stream satisfying capy::Stream and provides TLS encryption using the OpenSSL library.
Derives from tls_stream to provide a runtime‐polymorphic interface. The TLS operations are implemented as coroutines that orchestrate reads and writes on the underlying stream.
Construction Modes
Two construction modes are supported:
‐ Owning: Pass stream by value. The openssl_stream takes ownership and the stream is moved into internal storage.
‐ Reference: Pass stream by pointer. The openssl_stream does not own the stream; the caller must ensure the stream outlives this object.
Example
tls_context ctx;
ctx.set_hostname("example.com");
ctx.set_verify_mode(tls_verify_mode::peer);
corosio::tcp_socket sock(ioc);
co_await sock.connect(endpoint);
// Reference mode - sock must outlive tls
corosio::openssl_stream tls(&sock, ctx);
auto [ec] = co_await tls.handshake(openssl_stream::client);
// Or owning mode - tls owns the socket
corosio::openssl_stream tls2(std::move(sock), ctx);
Member Functions
Name |
Description |
|
Constructors |
|
Destructor. |
|
Assignment operators |
|
|
|
|
|
|
Initiate an asynchronous read operation. |
|
|
|
Initiate an asynchronous write operation. |
Protected Member Functions
Name |
|
|
See Also
tls_stream, wolfssl_stream
Created with MrDocs