boost::corosio::tls_context::set_servername_callback
Set a callback for Server Name Indication (SNI).
Synopsis
Declared in <boost/corosio/tls_context.hpp>
template<typename Callback>
void
set_servername_callback(Callback callback);
Description
For server connections, this callback is invoked during the TLS handshake when a client sends an SNI extension. The callback receives the requested hostname and can accept or reject the connection.
Example
// Accept connections for specific domains only
ctx.set_servername_callback(
[]( std::string_view hostname ) -> bool
{
return hostname == "api.example.com" ||
hostname == "www.example.com";
});
|
For virtual hosting with different certificates per hostname, create separate contexts and select the appropriate one before creating the TLS stream. |
Template Parameters
| Name | Description |
|---|---|
Callback |
A callable with signature |
Parameters
| Name | Description |
|---|---|
callback |
The SNI callback. Return |
See Also
set_hostname
Created with MrDocs