asio C++ library

PrevUpHomeNext

ssl::rfc2818_verification

Verifies a certificate against a hostname according to the rules described in RFC 2818.

class rfc2818_verification
Types

Name

Description

result_type

The type of the function object's result.

Member Functions

Name

Description

operator()

Perform certificate verification.

rfc2818_verification

Constructor.

Example

The following example shows how to synchronously open a secure connection to a given host name:

using asio::ip::tcp;
namespace ssl = asio::ssl;
typedef ssl::stream<tcp::socket> ssl_socket;

// Create a context that uses the default paths for finding CA certificates.
ssl::context ctx(ssl::context::sslv23);
ctx.set_default_verify_paths();

// Open a socket and connect it to the remote host.
asio::io_service io_service;
ssl_socket sock(io_service, ctx);
tcp::resolver resolver(io_service);
tcp::resolver::query query("host.name", "https");
asio::connect(sock.lowest_layer(), resolver.resolve(query));
sock.lowest_layer().set_option(tcp::no_delay(true));

// Perform SSL handshake and verify the remote host's certificate.
sock.set_verify_mode(ssl::verify_peer);
sock.set_verify_callback(ssl::rfc2818_verification("host.name"));
sock.handshake(ssl_socket::client);

// ... read and write as normal ...
Requirements

Header: asio/ssl/rfc2818_verification.hpp

Convenience header: asio/ssl.hpp


PrevUpHomeNext