Skip to content

Commit

Permalink
shrpx: Create default SSL context once
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsuhiro-t committed Jun 21, 2013
1 parent 7be1c0b commit 7b59a11
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
15 changes: 15 additions & 0 deletions src/shrpx.cc
Expand Up @@ -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.";
Expand Down
13 changes: 0 additions & 13 deletions src/shrpx_config.cc
Expand Up @@ -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;
}

Expand Down

0 comments on commit 7b59a11

Please sign in to comment.