Skip to content

Commit

Permalink
fix: tls connect error
Browse files Browse the repository at this point in the history
Signed-off-by: Dengfeng Liu <[email protected]>
  • Loading branch information
liudf0716 committed Jul 22, 2024
1 parent 636a85b commit caf6883
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
23 changes: 9 additions & 14 deletions src/gateway.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,14 @@ wd_zeroing_malloc(size_t howmuch) {
static void
openssl_init(void)
{
if (!RAND_poll()) return;
if (!RAND_poll()) {
debug(LOG_ERR, "Could not seed the PRNG");
exit(EXIT_FAILURE);
}

#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
(defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
// Initialize OpenSSL
CRYPTO_set_mem_functions (wd_zeroing_malloc, realloc, free);
SSL_library_init();
ERR_load_crypto_strings();
SSL_load_error_strings();
OpenSSL_add_all_algorithms();
debug (LOG_DEBUG, "Using OpenSSL version \"%s\"\nand libevent version \"%s\"\n",
SSLeay_version (SSLEAY_VERSION),
event_get_version ());
#else
debug (LOG_DEBUG, "Using OpenSSL version \"%s\"\nand libevent version \"%s\"\n",
OpenSSL_version (OPENSSL_VERSION),
event_get_version ());
#endif
}

static void
Expand Down Expand Up @@ -459,6 +449,8 @@ http_redir_loop(s_config *config)
SSL *ssl = SSL_new(ssl_ctx);
if (!ssl) termination_handler(0);

SSL_set_tlsext_host_name(ssl, config->gw_address);

base = event_base_new();
if (!base) termination_handler(0);

Expand Down Expand Up @@ -495,6 +487,9 @@ http_redir_loop(s_config *config)

evhttp_free(http);
event_base_free(base);

if (ssl_ctx) SSL_CTX_free(ssl_ctx);
if (ssl) SSL_free(ssl);
}

/**@internal
Expand Down
3 changes: 2 additions & 1 deletion src/wd_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ wd_request_context_new(struct event_base *base, SSL *ssl, int authserv_use_ssl)
}
if (!bev) return NULL;

bufferevent_openssl_set_allow_dirty_shutdown(bev, 1);
if (authserv_use_ssl)
bufferevent_openssl_set_allow_dirty_shutdown(bev, 1);

struct wd_request_context * context = safe_malloc(sizeof(struct wd_request_context));
context->base = base;
Expand Down

0 comments on commit caf6883

Please sign in to comment.