nghttpx: Use std::string for Downstream::backend_tls_sni_name
This commit is contained in:
parent
34d5382d66
commit
2c7ed01f0c
|
@ -1599,7 +1599,7 @@ int parse_config(const char *opt, const char *optarg,
|
|||
|
||||
return 0;
|
||||
case SHRPX_OPTID_BACKEND_TLS_SNI_FIELD:
|
||||
mod_config()->backend_tls_sni_name = strcopy(optarg);
|
||||
mod_config()->backend_tls_sni_name = optarg;
|
||||
|
||||
return 0;
|
||||
case SHRPX_OPTID_PID_FILE:
|
||||
|
|
|
@ -310,6 +310,7 @@ struct Config {
|
|||
// field. This is only used when user defined static obfuscated
|
||||
// string is provided.
|
||||
std::string forwarded_for_obfuscated;
|
||||
std::string backend_tls_sni_name;
|
||||
std::chrono::seconds tls_session_timeout;
|
||||
ev_tstamp http2_upstream_read_timeout;
|
||||
ev_tstamp upstream_read_timeout;
|
||||
|
@ -329,7 +330,6 @@ struct Config {
|
|||
std::unique_ptr<char[]> private_key_passwd;
|
||||
std::unique_ptr<char[]> cert_file;
|
||||
std::unique_ptr<char[]> dh_param_file;
|
||||
std::unique_ptr<char[]> backend_tls_sni_name;
|
||||
std::unique_ptr<char[]> pid_file;
|
||||
std::unique_ptr<char[]> conf_path;
|
||||
std::unique_ptr<char[]> ciphers;
|
||||
|
|
|
@ -335,8 +335,8 @@ int Http2Session::initiate_connection() {
|
|||
}
|
||||
|
||||
const char *sni_name = nullptr;
|
||||
if (get_config()->backend_tls_sni_name) {
|
||||
sni_name = get_config()->backend_tls_sni_name.get();
|
||||
if (!get_config()->backend_tls_sni_name.empty()) {
|
||||
sni_name = get_config()->backend_tls_sni_name.c_str();
|
||||
} else {
|
||||
sni_name = downstream_addr.host.c_str();
|
||||
}
|
||||
|
|
|
@ -971,10 +971,11 @@ int check_cert(SSL *ssl, const DownstreamAddr *addr) {
|
|||
<< X509_verify_cert_error_string(verify_res);
|
||||
return -1;
|
||||
}
|
||||
auto hostname = get_config()->backend_tls_sni_name
|
||||
? get_config()->backend_tls_sni_name.get()
|
||||
: addr->host.c_str();
|
||||
if (verify_hostname(cert, hostname, strlen(hostname), &addr->addr) != 0) {
|
||||
auto hostname = !get_config()->backend_tls_sni_name.empty()
|
||||
? StringAdaptor(get_config()->backend_tls_sni_name)
|
||||
: StringAdaptor(addr->host);
|
||||
if (verify_hostname(cert, hostname.c_str(), hostname.size(), &addr->addr) !=
|
||||
0) {
|
||||
LOG(ERROR) << "Certificate verification failed: hostname does not match";
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue