Loading...
Searching...
No Matches
websocketpp::transport::asio::tls_socket::connection Class Reference

TLS enabled Asio connection socket component. More...

`#include <tls.hpp>`

Inheritance diagram for websocketpp::transport::asio::tls_socket::connection:

## Public Types

typedef connection | type
| Type of this connection socket component.
typedef lib::shared_ptr< type > | ptr
| Type of a shared pointer to this connection socket component.
typedef lib::asio::ssl::stream< lib::asio::ip::tcp::socket > | socket_type
| Type of the ASIO socket being used.
typedef lib::shared_ptr< socket_type > | socket_ptr
| Type of a shared pointer to the ASIO socket being used.
typedef lib::asio::io_context * | io_context_ptr
| Type of a pointer to the ASIO io_context being used.
typedef lib::shared_ptr< lib::asio::io_context::strand > | strand_ptr
| Type of a pointer to the ASIO io_context strand being used.
typedef lib::shared_ptr< lib::asio::ssl::context > | context_ptr
| Type of a shared pointer to the ASIO TLS context being used.

## Public Member Functions

ptr | get_shared ()
| Get a shared pointer to this component.
bool | is_secure () const
| Check whether or not this connection is secure.
socket_type::lowest_layer_type & | get_raw_socket ()
| Retrieve a pointer to the underlying socket.
socket_type::next_layer_type & | get_next_layer ()
| Retrieve a pointer to the layer below the ssl stream.
socket_type & | get_socket ()
| Retrieve a pointer to the wrapped socket.
void | set_socket_init_handler (socket_init_handler h)
| Set the socket initialization handler.
void | set_tls_init_handler (tls_init_handler h)
| Set TLS init handler.
std::string | get_remote_endpoint (lib::error_code &ec) const
| Get the remote endpoint address.

## Static Public Member Functions

template<typename ErrorCodeType>
static lib::error_code | translate_ec (ErrorCodeType ec)
| Translate any security policy specific information about an error code.
static lib::error_code | translate_ec (lib::error_code ec)

## Protected Member Functions

lib::error_code | init_asio (io_context_ptr context, strand_ptr strand, bool is_server)
| Perform one time initializations.
void | set_uri (uri_ptr u)
| Set hostname hook.
void | pre_init (init_handler callback)
| Pre-initialize security policy.
void | post_init (init_handler callback)
| Post-initialize security policy.
void | set_handle (connection_hdl hdl)
| Sets the connection handle.
void | handle_init (init_handler callback, lib::asio::error_code const &ec)
lib::error_code | get_ec () const
lib::asio::error_code | cancel_socket ()
| Cancel all async operations on this socket.
void | async_shutdown (socket::shutdown_handler callback)

## Detailed Description

TLS enabled Asio connection socket component.

transport::asio::tls_socket::connection implements a secure connection socket component that uses Asio's ssl::stream to wrap an ip::tcp::socket.

Definition at line 63 of file tls.hpp.

## Member Typedef Documentation

## context_ptr

typedef lib::shared_ptr<lib::asio::ssl::context> websocketpp::transport::asio::tls_socket::connection::context_ptr

Type of a shared pointer to the ASIO TLS context being used.

Definition at line 79 of file tls.hpp.

## io_context_ptr

typedef lib::asio::io_context* websocketpp::transport::asio::tls_socket::connection::io_context_ptr

Type of a pointer to the ASIO io_context being used.

Definition at line 75 of file tls.hpp.

## ptr

typedef lib::shared_ptr<type> websocketpp::transport::asio::tls_socket::connection::ptr

Type of a shared pointer to this connection socket component.

Definition at line 68 of file tls.hpp.

## socket_ptr

typedef lib::shared_ptr<socket_type> websocketpp::transport::asio::tls_socket::connection::socket_ptr

Type of a shared pointer to the ASIO socket being used.

Definition at line 73 of file tls.hpp.

## socket_type

typedef lib::asio::ssl::stream<lib::asio::ip::tcp::socket> websocketpp::transport::asio::tls_socket::connection::socket_type

Type of the ASIO socket being used.

Definition at line 71 of file tls.hpp.

## strand_ptr

typedef lib::shared_ptr<lib::asio::io_context::strand> websocketpp::transport::asio::tls_socket::connection::strand_ptr

Type of a pointer to the ASIO io_context strand being used.

Definition at line 77 of file tls.hpp.

## type

typedef connection websocketpp::transport::asio::tls_socket::connection::type

Type of this connection socket component.

Definition at line 66 of file tls.hpp.

## Constructor & Destructor Documentation

## connection()

websocketpp::transport::asio::tls_socket::connection::connection | ( |  | ) |

inline explicit

Definition at line 81 of file tls.hpp.

## Member Function Documentation

## async_shutdown()

void websocketpp::transport::asio::tls_socket::connection::async_shutdown | ( | socket::shutdown_handler | callback | ) |

inline protected

Definition at line 338 of file tls.hpp.

## cancel_socket()

lib::asio::error_code websocketpp::transport::asio::tls_socket::connection::cancel_socket | ( |  | ) |

inline protected

Cancel all async operations on this socket.

Attempts to cancel all async operations on this socket and reports any failures.

NOTE: Windows XP and earlier do not support socket cancellation.

Returns
  The error that occurred, if any.

Definition at line 332 of file tls.hpp.

## get_ec()

lib::error_code websocketpp::transport::asio::tls_socket::connection::get_ec | ( |  | ) | const

inline protected

Definition at line 319 of file tls.hpp.

## get_next_layer()

socket_type::next_layer_type & websocketpp::transport::asio::tls_socket::connection::get_next_layer | ( |  | ) |

inline

Retrieve a pointer to the layer below the ssl stream.

This is used internally.

Definition at line 111 of file tls.hpp.

## get_raw_socket()

socket_type::lowest_layer_type & websocketpp::transport::asio::tls_socket::connection::get_raw_socket | ( |  | ) |

inline

Retrieve a pointer to the underlying socket.

This is used internally. It can also be used to set socket options, etc

Definition at line 103 of file tls.hpp.

## get_remote_endpoint()

std::string websocketpp::transport::asio::tls_socket::connection::get_remote_endpoint | ( | lib::error_code & | ec | ) | const

inline

Get the remote endpoint address.

The iostream transport has no information about the ultimate remote endpoint. It will return the string "iostream transport". To indicate this.

TODO: allow user settable remote endpoint addresses if this seems useful

Returns
  A string identifying the address of the remote endpoint

Definition at line 158 of file tls.hpp.

## get_shared()

ptr websocketpp::transport::asio::tls_socket::connection::get_shared | ( |  | ) |

inline

Get a shared pointer to this component.

Definition at line 87 of file tls.hpp.

## get_socket()

socket_type & websocketpp::transport::asio::tls_socket::connection::get_socket | ( |  | ) |

inline

Retrieve a pointer to the wrapped socket.

This is used internally.

Definition at line 119 of file tls.hpp.

## handle_init()

void websocketpp::transport::asio::tls_socket::connection::handle_init | ( | init_handler | callback,
|  | lib::asio::error_code const & | ec )

inline protected

Definition at line 309 of file tls.hpp.

## init_asio()

lib::error_code websocketpp::transport::asio::tls_socket::connection::init_asio | ( | io_context_ptr | context,
|  | strand_ptr | strand,
|  | bool | is_server )

inline protected

Perform one time initializations.

init_asio is called once immediately after construction to initialize Asio components to the io_context

Parameters

  context | A pointer to the endpoint's io_context
  strand | A pointer to the connection's strand
  is_server | Whether or not the endpoint is a server or not.

Definition at line 185 of file tls.hpp.

## is_secure()

bool websocketpp::transport::asio::tls_socket::connection::is_secure | ( |  | ) | const

inline

Check whether or not this connection is secure.

Returns
  Whether or not this connection is secure

Definition at line 95 of file tls.hpp.

## post_init()

void websocketpp::transport::asio::tls_socket::connection::post_init | ( | init_handler | callback | ) |

inline protected

Post-initialize security policy.

Called by the transport after all intermediate proxies have been negotiated. This gives the security policy the chance to talk with the real remote endpoint for a bit before the websocket handshake.

Parameters

  callback | Handler to call back with completion information

Definition at line 273 of file tls.hpp.

## pre_init()

void websocketpp::transport::asio::tls_socket::connection::pre_init | ( | init_handler | callback | ) |

inline protected

Pre-initialize security policy.

Called by the transport after a new connection is created to initialize the socket component of the connection. This method is not allowed to write any bytes to the wire. This initialization happens before any proxies or other intermediate wrappers are negotiated.

Parameters

  callback | Handler to call back with completion information

Definition at line 230 of file tls.hpp.

## set_handle()

void websocketpp::transport::asio::tls_socket::connection::set_handle | ( | connection_hdl | hdl | ) |

inline protected

Sets the connection handle.

The connection handle is passed to any handlers to identify the connection

Parameters

  hdl | The new handle

Definition at line 305 of file tls.hpp.

## set_socket_init_handler()

void websocketpp::transport::asio::tls_socket::connection::set_socket_init_handler | ( | socket_init_handler | h | ) |

inline

Set the socket initialization handler.

The socket initialization handler is called after the socket object is created but before it is used. This gives the application a chance to set any ASIO socket options it needs.

Parameters

  h | The new socket_init_handler

Definition at line 131 of file tls.hpp.

## set_tls_init_handler()

void websocketpp::transport::asio::tls_socket::connection::set_tls_init_handler | ( | tls_init_handler | h | ) |

inline

Set TLS init handler.

The tls init handler is called when needed to request a TLS context for the library to use. A TLS init handler must be set and it must return a valid TLS context in order for this endpoint to be able to initialize TLS connections

Parameters

  h | The new tls_init_handler

Definition at line 144 of file tls.hpp.

## set_uri()

void websocketpp::transport::asio::tls_socket::connection::set_uri | ( | uri_ptr | u | ) |

inline protected

Set hostname hook.

Called by the transport as a connection is being established to provide the hostname being connected to to the security/socket layer.

This socket policy uses the hostname to set the appropriate TLS SNI header.

Since
  0.6.0

Parameters

  u | The uri to set

Definition at line 217 of file tls.hpp.

## translate_ec() [1/2]

template<typename ErrorCodeType>

lib::error_code websocketpp::transport::asio::tls_socket::connection::translate_ec | ( | ErrorCodeType | ec | ) |

inline static

Translate any security policy specific information about an error code.

Translate_ec takes an Asio error code and attempts to convert its value to an appropriate websocketpp error code. In the case that the Asio and Websocketpp error types are the same (such as using boost::asio and boost::system_error or using standalone asio and std::system_error the code will be passed through natively.

In the case of a mismatch (boost::asio with std::system_error) a translated code will be returned. Any error that is determined to be related to TLS but does not have a more specific websocketpp error code is returned under the catch all error tls_error. Non-TLS related errors are returned as the transport generic error pass_through

Since
  0.3.0

Parameters

  ec | The error code to translate_ec

Returns
  The translated error code

Definition at line 368 of file tls.hpp.

## translate_ec() [2/2]

lib::error_code websocketpp::transport::asio::tls_socket::connection::translate_ec | ( | lib::error_code | ec | ) |

inline static

Overload of translate_ec to catch cases where lib::error_code is the same type as lib::asio::error_code

Definition at line 383 of file tls.hpp.

The documentation for this class was generated from the following file:

- websocketpp/transport/asio/security/tls.hpp