boost::corosio::openssl_stream

A TLS stream using OpenSSL.

Synopsis

class openssl_stream
    : public tls_stream

Description

This class wraps an underlying stream derived from io_stream and provides TLS encryption using the OpenSSL library.

Inherits handshake(), shutdown(), read_some(), and write_some() from tls_stream.

Thread Safety

Distinct objects: Safe. Shared objects: Unsafe.

Example

tls::context ctx;
ctx.set_hostname( "example.com" );
ctx.set_verify_mode( tls::verify_mode::peer );

corosio::socket raw_socket( ioc );
raw_socket.open();
co_await raw_socket.connect( endpoint );

corosio::openssl_stream secure( raw_socket, ctx );
co_await secure.handshake( openssl_stream::client );
// Use secure stream for TLS communication

Base Classes

Name Description

tls_stream

Abstract base class for TLS streams.

Enums

Name

Description

handshake_type

Different handshake types.

Member Functions

Name

Description

openssl_stream [constructor]

Construct an OpenSSL stream.

~openssl_stream [destructor] [virtual]

Destructor.

context

Return the execution context.

get_impl

Returns the underlying implementation.

handshake

Perform the TLS handshake asynchronously.

next_layer

next_layer overloads

read_some

Initiate an asynchronous read operation.

shutdown

Perform a graceful TLS shutdown asynchronously.

write_some

Initiate an asynchronous write operation.

Protected Data Members

Name

ctx_

impl_

s_

Non-Member Functions

Name

Description

read

Read from a stream until the buffer is full or an error occurs.

read

Read from a stream into a string until EOF or an error occurs.

write

Write to a stream until the buffer is empty or an error occurs.

Created with MrDocs