Skip to content

feature: use the actual ngx_connection_t * in ssl_client_hello_by #2416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/ngx_http_lua_ssl_client_helloby.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,7 @@ ngx_http_lua_ffi_ssl_get_client_hello_ext_present(ngx_http_request_t *r,
int got_extensions;
size_t ext_len;
int *ext_out;
/* OPENSSL will allocate memory for us and make the ext_out point to it */

ngx_connection_t *c;

if (r->connection == NULL || r->connection->ssl == NULL) {
*err = "bad request";
Expand All @@ -684,6 +683,13 @@ ngx_http_lua_ffi_ssl_get_client_hello_ext_present(ngx_http_request_t *r,
return NGX_ERROR;
}

c = ngx_ssl_get_connection(ssl_conn);
if (c == NULL) {
*err = "couldn't get real ngx_connection_t pointer";
return NGX_ERROR;
}


#ifdef SSL_ERROR_WANT_CLIENT_HELLO_CB
got_extensions = SSL_client_hello_get1_extensions_present(ssl_conn,
&ext_out, &ext_len);
Expand All @@ -692,7 +698,7 @@ ngx_http_lua_ffi_ssl_get_client_hello_ext_present(ngx_http_request_t *r,
return NGX_DECLINED;
}

*extensions = ngx_palloc(r->connection->pool, sizeof(int) * ext_len);
*extensions = ngx_palloc(c->pool, sizeof(int) * ext_len);
if (*extensions != NULL) {
ngx_memcpy(*extensions, ext_out, sizeof(int) * ext_len);
*extensions_len = ext_len;
Expand Down