mirror of
https://gitee.com/openharmony/third_party_nghttp2
synced 2024-11-23 07:50:02 +00:00
Fix up OpenSSL initialization
Use the example presented at http://en.wikibooks.org/wiki/OpenSSL/Initialization
This commit is contained in:
parent
1c06cfd29f
commit
791660ef8d
@ -689,10 +689,10 @@ int main(int argc, char **argv) {
|
||||
act.sa_handler = SIG_IGN;
|
||||
sigaction(SIGPIPE, &act, 0);
|
||||
|
||||
OPENSSL_config(NULL);
|
||||
OpenSSL_add_all_algorithms();
|
||||
SSL_load_error_strings();
|
||||
SSL_library_init();
|
||||
OpenSSL_add_all_algorithms();
|
||||
OPENSSL_config(NULL);
|
||||
|
||||
rv = parse_uri(&uri, argv[1]);
|
||||
if (rv != 0) {
|
||||
|
@ -551,10 +551,10 @@ int main(int argc, char **argv) {
|
||||
act.sa_handler = SIG_IGN;
|
||||
sigaction(SIGPIPE, &act, NULL);
|
||||
|
||||
OPENSSL_config(NULL);
|
||||
OpenSSL_add_all_algorithms();
|
||||
SSL_load_error_strings();
|
||||
SSL_library_init();
|
||||
OpenSSL_add_all_algorithms();
|
||||
OPENSSL_config(NULL);
|
||||
|
||||
run(argv[1]);
|
||||
return 0;
|
||||
|
@ -724,10 +724,10 @@ int main(int argc, char **argv) {
|
||||
act.sa_handler = SIG_IGN;
|
||||
sigaction(SIGPIPE, &act, NULL);
|
||||
|
||||
OPENSSL_config(NULL);
|
||||
OpenSSL_add_all_algorithms();
|
||||
SSL_load_error_strings();
|
||||
SSL_library_init();
|
||||
OpenSSL_add_all_algorithms();
|
||||
OPENSSL_config(NULL);
|
||||
|
||||
run(argv[1], argv[2], argv[3]);
|
||||
return 0;
|
||||
|
@ -1063,6 +1063,14 @@ Options:
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
#ifndef NOTHREADS
|
||||
ssl::LibsslGlobalLock lock;
|
||||
#endif // NOTHREADS
|
||||
SSL_load_error_strings();
|
||||
SSL_library_init();
|
||||
OpenSSL_add_all_algorithms();
|
||||
OPENSSL_config(nullptr);
|
||||
|
||||
std::string datafile;
|
||||
while (1) {
|
||||
static int flag = 0;
|
||||
@ -1259,14 +1267,6 @@ int main(int argc, char **argv) {
|
||||
memset(&act, 0, sizeof(struct sigaction));
|
||||
act.sa_handler = SIG_IGN;
|
||||
sigaction(SIGPIPE, &act, nullptr);
|
||||
OPENSSL_config(nullptr);
|
||||
OpenSSL_add_all_algorithms();
|
||||
SSL_load_error_strings();
|
||||
SSL_library_init();
|
||||
|
||||
#ifndef NOTHREADS
|
||||
ssl::LibsslGlobalLock lock;
|
||||
#endif // NOTHREADS
|
||||
|
||||
auto ssl_ctx = SSL_CTX_new(SSLv23_client_method());
|
||||
if (!ssl_ctx) {
|
||||
|
@ -2400,6 +2400,11 @@ Options:
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
SSL_load_error_strings();
|
||||
SSL_library_init();
|
||||
OpenSSL_add_all_algorithms();
|
||||
OPENSSL_config(nullptr);
|
||||
|
||||
bool color = false;
|
||||
while (1) {
|
||||
static int flag = 0;
|
||||
@ -2639,10 +2644,6 @@ int main(int argc, char **argv) {
|
||||
memset(&act, 0, sizeof(struct sigaction));
|
||||
act.sa_handler = SIG_IGN;
|
||||
sigaction(SIGPIPE, &act, nullptr);
|
||||
OPENSSL_config(nullptr);
|
||||
OpenSSL_add_all_algorithms();
|
||||
SSL_load_error_strings();
|
||||
SSL_library_init();
|
||||
reset_timer();
|
||||
return run(argv + optind, argc - optind);
|
||||
}
|
||||
|
@ -168,6 +168,14 @@ Options:
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
#ifndef NOTHREADS
|
||||
ssl::LibsslGlobalLock lock;
|
||||
#endif // NOTHREADS
|
||||
SSL_load_error_strings();
|
||||
SSL_library_init();
|
||||
OpenSSL_add_all_algorithms();
|
||||
OPENSSL_config(nullptr);
|
||||
|
||||
Config config;
|
||||
bool color = false;
|
||||
while (1) {
|
||||
@ -359,13 +367,6 @@ int main(int argc, char **argv) {
|
||||
memset(&act, 0, sizeof(struct sigaction));
|
||||
act.sa_handler = SIG_IGN;
|
||||
sigaction(SIGPIPE, &act, nullptr);
|
||||
OPENSSL_config(nullptr);
|
||||
OpenSSL_add_all_algorithms();
|
||||
SSL_load_error_strings();
|
||||
SSL_library_init();
|
||||
#ifndef NOTHREADS
|
||||
ssl::LibsslGlobalLock lock;
|
||||
#endif // NOTHREADS
|
||||
|
||||
reset_timer();
|
||||
|
||||
|
21
src/shrpx.cc
21
src/shrpx.cc
@ -1415,6 +1415,16 @@ Misc:
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
#ifndef NOTHREADS
|
||||
nghttp2::ssl::LibsslGlobalLock lock;
|
||||
#endif // NOTHREADS
|
||||
// Initialize OpenSSL before parsing options because we create
|
||||
// SSL_CTX there.
|
||||
SSL_load_error_strings();
|
||||
SSL_library_init();
|
||||
OpenSSL_add_all_algorithms();
|
||||
OPENSSL_config(nullptr);
|
||||
|
||||
Log::set_severity_level(NOTICE);
|
||||
create_config();
|
||||
fill_default_config();
|
||||
@ -1894,13 +1904,6 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize OpenSSL before parsing options because we create
|
||||
// SSL_CTX there.
|
||||
OPENSSL_config(nullptr);
|
||||
OpenSSL_add_all_algorithms();
|
||||
SSL_load_error_strings();
|
||||
SSL_library_init();
|
||||
|
||||
if (conf_exists(get_config()->conf_path.get())) {
|
||||
if (load_config(get_config()->conf_path.get()) == -1) {
|
||||
LOG(FATAL) << "Failed to load configuration from "
|
||||
@ -1925,10 +1928,6 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NOTHREADS
|
||||
auto lock = make_unique<nghttp2::ssl::LibsslGlobalLock>();
|
||||
#endif // NOTHREADS
|
||||
|
||||
if (get_config()->accesslog_syslog || get_config()->errorlog_syslog) {
|
||||
openlog("nghttpx", LOG_NDELAY | LOG_NOWAIT | LOG_PID,
|
||||
get_config()->syslog_facility);
|
||||
|
Loading…
Reference in New Issue
Block a user