Skip to content

Commit c63009c

Browse files
authored
bugfix: remove sslhandshake result assert for pre-handshake errors. (#534)
When `tcpsock:sslhandshake()` fails before the actual SSL handshake starts, `ngx_http_lua_ffi_socket_tcp_get_sslhandshake_result()` may return `FFI_OK` while still providing the OpenSSL error details. One example is a client private key setup failure. In that path, `rc` is `FFI_ERROR`, but `u->error_ret` is not set, so `ngx_http_lua_ffi_socket_tcp_get_sslhandshake_result` would return `FFI_OK`. The existing `assert(res == FFI_ERROR)` turns this expected error-reporting path into an assertion failure. This patch removes the assertion so Lua can return the original SSL error to the caller.
1 parent cfb5825 commit c63009c

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

lib/resty/core/socket.lua

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,14 +424,10 @@ local function sslhandshake(cosocket, reused_session, server_name, ssl_verify,
424424
error("no request ctx found", 2)
425425
end
426426

427-
local res
428-
429427
if rc == FFI_ERROR then
430-
res = C.ngx_http_lua_ffi_socket_tcp_get_sslhandshake_result(r, u,
428+
C.ngx_http_lua_ffi_socket_tcp_get_sslhandshake_result(r, u,
431429
session_ptr, errmsg, openssl_error_code)
432430

433-
assert(res == FFI_ERROR)
434-
435431
if openssl_error_code[0] ~= 0 then
436432
return nil, openssl_error_code[0] .. ": " .. ffi_str(errmsg[0])
437433
end
@@ -443,6 +439,8 @@ local function sslhandshake(cosocket, reused_session, server_name, ssl_verify,
443439
return reused_session
444440
end
445441

442+
local res
443+
446444
if rc == FFI_OK then
447445
if reused_session == false then
448446
return true

0 commit comments

Comments
 (0)