Skip to content
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
10 changes: 8 additions & 2 deletions src/ngx_http_lua_ssl_certby.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,14 @@ ngx_http_lua_ssl_cert_handler(ngx_ssl_conn_t *ssl_conn, void *data)

c->log->action = "loading SSL certificate by lua";

rc = lscf->srv.ssl_cert_handler(r, lscf, L);

if (lscf->srv.ssl_cert_handler) {
Copy link
Member

@agentzh agentzh Apr 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pointer can never be NULL when it is already in this ngx_http_lua_ssl_cert_handler function. And we never observe NULL pointers in some user company's global SSL gateway network. I guess it's something else, like some 3rd-party NGINX C modules or 3rd-party Lua C or FFI libraries you are using, which corrupt memory. This does not look like the culprit. Better dig things up instead of working around the real issue which might be somewhere else.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I have to go deeper and find out the real reason of null pointer.
But, anyway,

  • There is only one 3rd party module I use, besides shipped with nginx and openresty: https://github.com/newobj/nginx-x-rid-header/blob/master/ngx_x_rid_header_module.c, it's quite simple and i'ts not the culprit for my mind.
  • I have used my build of nginx for rather long time, with no segfaults just untill I've added only one line: "ssl_certificate_by_lua_block { return }"
  • there are no any other block of lua code in my config
  • It seems, I've somehow localized this issue,. My nginx crashes after request from IP addresses which use okhttp/3.3.1 client (it's java http client for android)

Some more info I've posted to https://groups.google.com/forum/#!topic/openresty-en/ym1oPD9fyLo

rc = lscf->srv.ssl_cert_handler(r, lscf, L);
} else {
ngx_ssl_error(NGX_LOG_ALERT, c->log, 0,
"srv.ssl_cert_handler is null");
goto failed;
}

if (rc >= NGX_OK || rc == NGX_ERROR) {
cctx->done = 1;

Expand Down