Skip to content
Open
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
14 changes: 7 additions & 7 deletions pgmoon/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -401,14 +401,14 @@ do
local server_cert = self.sock:getpeercertificate()
pem, signature = server_cert:pem(), server_cert:getsignaturename()
end
signature = signature:lower()
local _, with_sig
_, _, with_sig = signature:find("%-with%-(.*)")
if with_sig then
signature = with_sig
end
if signature:match("^md5") or signature:match("^sha1") or signature:match("sha1$") then
local sig_lower = signature:lower()
if sig_lower:match("^md5") or sig_lower:match("^sha1") or sig_lower:match("sha1$") or sig_lower:match("sha256$") then
signature = "sha256"
else
local objects = require("resty.openssl.objects")
local sigid = assert(objects.txt2nid(signature))
local digest_nid = assert(objects.find_sigid_algs(sigid))
signature = assert(objects.nid2table(digest_nid).sn)
end
cbind_data = assert(x509_digest(pem, signature))
end
Expand Down
14 changes: 7 additions & 7 deletions pgmoon/init.moon
Original file line number Diff line number Diff line change
Expand Up @@ -404,16 +404,16 @@ class Postgres
server_cert = @sock\getpeercertificate()
server_cert\pem!, server_cert\getsignaturename!

signature = signature\lower!

-- Handle the case when the signature is e.g. ECDSA-with-SHA384
_, _, with_sig = signature\find("%-with%-(.*)")
if with_sig
signature = with_sig
sig_lower = signature\lower!

-- upgrade the signature if necessary (also handle the case of s/RSA-SHA1/sha256)
if signature\match("^md5") or signature\match("^sha1") or signature\match("sha1$")
if sig_lower\match("^md5") or sig_lower\match("^sha1") or sig_lower\match("sha1$") or sig_lower\match("sha256$")
signature = "sha256"
else
objects = require "resty.openssl.objects"
sigid = assert objects.txt2nid(signature)
digest_nid = assert objects.find_sigid_algs(sigid)
signature = assert objects.nid2table(digest_nid).sn

assert x509_digest(pem, signature)

Expand Down