boost::corosio::tls_context::set_hostname

Set the expected server hostname for verification.

Synopsis

void
set_hostname(std::string_view hostname);

Description

For client connections, sets the hostname that the server certificate must match. This enables:

1. SNI (Server Name Indication) — tells the server which certificate to present (for virtual hosting) 2. Hostname verification — validates the certificate's Subject Alternative Name or Common Name matches

Example

ctx.set_hostname( "api.example.com" );

This is typically required for HTTPS clients to ensure they're connecting to the intended server.

Parameters

Name Description

hostname

The expected server hostname.

Created with MrDocs