@@ -32,7 +32,7 @@ new file mode 100644
3232index 0000000..89454ad
3333--- /dev/null
3434+++ lib/resty/core/socket/tcp.lua
35- @@ -0,0 +1,277 @@
35+ @@ -0,0 +1,284 @@
3636+ -- Copyright (C) by OpenResty Inc.
3737+
3838+
@@ -141,6 +141,15 @@ index 0000000..89454ad
141141+ end
142142+
143143+
144+ + local function report_handshake_error(errmsg, openssl_error_code)
145+ + if openssl_error_code[0] ~= 0 then
146+ + return nil, openssl_error_code[0] .. ": " .. ffi_str(errmsg[0])
147+ + end
148+ +
149+ + return nil, ffi_str(errmsg[0])
150+ + end
151+ +
152+ +
144153+ local function tlshandshake(self, options)
145154+ if not options then
146155+ clear_tab(cached_options)
@@ -241,7 +250,9 @@ index 0000000..89454ad
241250+ rc = ngx_lua_ffi_socket_tcp_get_tlshandshake_result(r, u,
242251+ session_ptr, errmsg, openssl_error_code)
243252+
244- + assert(rc == FFI_OK)
253+ + if rc == FFI_ERROR then
254+ + return report_handshake_error(errmsg, openssl_error_code)
255+ + end
245256+
246257+ if session_ptr[0] == nil then
247258+ return nil
@@ -258,11 +269,7 @@ index 0000000..89454ad
258269+ session_ptr, errmsg, openssl_error_code)
259270+
260271+ if rc == FFI_ERROR then
261- + if openssl_error_code[0] ~= 0 then
262- + return nil, openssl_error_code[0] .. ": " .. ffi_str(errmsg[0])
263- + end
264- +
265- + return nil, ffi_str(errmsg[0])
272+ + return report_handshake_error(errmsg, openssl_error_code)
266273+ end
267274+ end
268275+ end
0 commit comments