Skip to content

Commit

Permalink
fix(mtls) use OpenResty's API for mtls (Kong#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
ADD-SP authored and AlinsRan committed Jun 2, 2023
1 parent bb5a3e1 commit 60b222a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/resty/healthcheck.lua
Original file line number Diff line number Diff line change
Expand Up @@ -918,9 +918,19 @@ function checker:run_single_check(ip, port, hostname, hostheader)
end

if self.checks.active.type == "https" then
local session
session, err = sock:sslhandshake(nil, hostname,
local https_sni, session, err
https_sni = self.checks.active.https_sni or hostheader or hostname
if self.ssl_cert and self.ssl_key then
ok, err = sock:setclientcert(self.ssl_cert, self.ssl_key)

if not ok then
self:log(ERR, "failed to set client certificate: ", err)
end
end

session, err = sock:sslhandshake(nil, https_sni,
self.checks.active.https_verify_certificate)

if not session then
sock:close()
self:log(ERR, "failed SSL handshake with '", hostname or "", " (", ip, ":", port, ")': ", err)
Expand Down

0 comments on commit 60b222a

Please sign in to comment.