mirror of
https://github.com/nghttp2/nghttp2.git
synced 2025-12-07 18:48:54 +08:00
shrpx: Create default SSL context once
This commit is contained in:
15
src/shrpx.cc
15
src/shrpx.cc
@@ -897,6 +897,21 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if(get_config()->cert_file && get_config()->private_key_file) {
|
||||
mod_config()->default_ssl_ctx =
|
||||
ssl::create_ssl_context(get_config()->private_key_file,
|
||||
get_config()->cert_file);
|
||||
if(get_config()->cert_tree) {
|
||||
if(ssl::cert_lookup_tree_add_cert_from_file(get_config()->cert_tree,
|
||||
get_config()->default_ssl_ctx,
|
||||
get_config()->cert_file)
|
||||
== -1) {
|
||||
LOG(FATAL) << "Failed to parse command-line argument.";
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(get_config()->backend_ipv4 && get_config()->backend_ipv6) {
|
||||
LOG(FATAL) << "--backend-ipv4 and --backend-ipv6 cannot be used at the "
|
||||
<< "same time.";
|
||||
|
||||
@@ -406,19 +406,6 @@ int parse_config(const char *opt, const char *optarg)
|
||||
LOG(ERROR) << "Unknown option: " << opt;
|
||||
return -1;
|
||||
}
|
||||
if(get_config()->cert_file && get_config()->private_key_file) {
|
||||
mod_config()->default_ssl_ctx =
|
||||
ssl::create_ssl_context(get_config()->private_key_file,
|
||||
get_config()->cert_file);
|
||||
if(get_config()->cert_tree) {
|
||||
if(ssl::cert_lookup_tree_add_cert_from_file(get_config()->cert_tree,
|
||||
get_config()->default_ssl_ctx,
|
||||
get_config()->cert_file)
|
||||
== -1) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user