Skip to content
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

fix(plugin/tcp-log):repeated sslhandshake in [tcp-log] plugin #11803

Merged
merged 7 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions changelog/unreleased/kong/fix-tcp-log-sslhandshake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
message: "**tcp-log**: fix an issue that repeated ssl handshake"
type: bugfix
scope: Plugin
11 changes: 9 additions & 2 deletions kong/plugins/tcp-log/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@ local function log(premature, conf, message)
return
end

if conf.tls then
ok, err = sock:sslhandshake(true, conf.tls_sni, false)
local times, err = sock:getreusedtimes()
if not times then
kong.log.err("failed to get socket reused time to ", host, ":", tostring(port), ": ", err)
sock:close()
return
end

if conf.tls and times == 0 then
ok, err = sock:sslhandshake(false, conf.tls_sni, false)
if not ok then
kong.log.err("failed to perform TLS handshake to ", host, ":", port, ": ", err)
sock:close()
Expand Down
Loading