|
NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
|
SNI (Server Name Indication) 证书管理器 更多...
#include <sni_manager.hpp>
Public 成员函数 | |
| void | add_host (const string &hostname, ssl_context ctx) |
| 添加域名及其SSL上下文 | |
| void | remove_host (const string &hostname) |
| 移除域名 | |
| void | set_default_context (ssl_context ctx) |
| 设置默认SSL上下文(SNI未匹配时使用) | |
| void * | select_ssl_ctx (const string &server_name) const |
| 根据SNI hostname选择SSL_CTX | |
| bool | has_host (const string &hostname) const |
| 检查是否有指定域名的证书 | |
| size_t | host_count () const noexcept |
| 获取配置的域名数量 | |
静态 Public 成员函数 | |
| static int | sni_callback (void *ssl, int *alert, void *arg) |
| SNI回调函数(用于SSL_CTX_set_tlsext_servername_callback) | |
SNI (Server Name Indication) 证书管理器
支持为不同域名配置不同的SSL证书。 在TLS握手时根据客户端SNI hostname自动选择合适的SSL_CTX。
使用示例:
在文件 sni_manager.hpp 第 39 行定义.
| void neforce::sni_manager::add_host | ( | const string & | hostname, |
| ssl_context | ctx ) |
添加域名及其SSL上下文
| hostname | 域名 |
| ctx | SSL上下文 |
| void neforce::sni_manager::remove_host | ( | const string & | hostname | ) |
移除域名
| hostname | 域名 |
|
nodiscard |
根据SNI hostname选择SSL_CTX
| server_name | 客户端发送的SNI hostname |
匹配规则:
| void neforce::sni_manager::set_default_context | ( | ssl_context | ctx | ) |
设置默认SSL上下文(SNI未匹配时使用)
| ctx | 默认SSL上下文 |
|
static |
SNI回调函数(用于SSL_CTX_set_tlsext_servername_callback)
此静态函数可作为OpenSSL的SNI回调,自动查询sni_manager实例。 通过SSL_CTX_set_tlsext_servername_arg设置manager指针。