Kurlyk
Loading...
Searching...
No Matches
SimpleWeb::SocketClient< WSS > Class Reference

A WebSocket client with SSL support. More...

#include <SocketClient.hpp>

Inheritance diagram for SimpleWeb::SocketClient< WSS >:

Public Member Functions

 SocketClient (const std::string &server_port_path, bool verify_certificate=true, const std::string &certification_file=std::string(), const std::string &private_key_file=std::string(), const std::string &verify_file=std::string())
 Constructs a WebSocket client with SSL/TLS support.
 

Protected Member Functions

void connect () override
 Initiates the connection process.
 
void handshake (const std::shared_ptr< Connection > &connection)
 Performs the SSL/TLS handshake.
 

Protected Attributes

asio::ssl::context context
 

Private Member Functions

void add_root_certificates ()
 Adds root certificates from the system to the SSL context.
 

Detailed Description

A WebSocket client with SSL support.

This class extends the SocketClientBase<WSS> class to provide SSL/TLS support for WebSocket connections. It allows you to connect to a WebSocket server over a secure connection using SSL/TLS. The class also includes functionality to load root certificates from the system to facilitate secure connections.

Definition at line 31 of file SocketClient.hpp.

Constructor & Destructor Documentation

◆ SocketClient()

SimpleWeb::SocketClient< WSS >::SocketClient ( const std::string & server_port_path,
bool verify_certificate = true,
const std::string & certification_file = std::string(),
const std::string & private_key_file = std::string(),
const std::string & verify_file = std::string() )
inline

Constructs a WebSocket client with SSL/TLS support.

Parameters
server_port_pathServer resource specified by host[:port][/path].
verify_certificateSet to true (default) to enable verification of the server's certificate and hostname according to RFC 2818.
certification_fileIf provided, specifies the file containing the client certificate to use. Requires private_key_file.
private_key_fileIf provided, specifies the file containing the private key corresponding to the client certificate. Requires certification_file.
verify_fileIf provided, specifies a certificate authority file for verification.

Definition at line 41 of file SocketClient.hpp.

Member Function Documentation

◆ add_root_certificates()

void SimpleWeb::SocketClient< WSS >::add_root_certificates ( )
inlineprivate

Adds root certificates from the system to the SSL context.

This method loads root certificates from the system certificate store and adds them to the SSL context. It is used when no specific certificate authority file is provided.

Definition at line 87 of file SocketClient.hpp.

◆ connect()

void SimpleWeb::SocketClient< WSS >::connect ( )
inlineoverrideprotected

Initiates the connection process.

This method starts the process of connecting to the WebSocket server, including resolving the server address and establishing the connection. It handles both direct and proxy connections and performs the necessary SSL/TLS handshake.

Definition at line 119 of file SocketClient.hpp.

◆ handshake()

void SimpleWeb::SocketClient< WSS >::handshake ( const std::shared_ptr< Connection > & connection)
inlineprotected

Performs the SSL/TLS handshake.

This method performs the SSL/TLS handshake with the WebSocket server. It sets the server name for SNI and handles the asynchronous handshake process. Once the handshake is complete, it calls the upgrade method to finalize the connection.

Parameters
connectionA shared pointer to the connection object.

Definition at line 206 of file SocketClient.hpp.

Member Data Documentation

◆ context

asio::ssl::context SimpleWeb::SocketClient< WSS >::context
protected

Definition at line 112 of file SocketClient.hpp.


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