Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 552b666

Browse files
committedJun 29, 2023
fix digest mapping for scram auth
1 parent 7b7ef2a commit 552b666

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
 

‎pgmoon/init.lua

+5
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,11 @@ do
409409
end
410410
if signature:match("^md5") or signature:match("^sha1") or signature:match("sha1$") then
411411
signature = "sha256"
412+
else
413+
local objects = require("resty.openssl.objects")
414+
local sigid = assert(objects.txt2nid(signature))
415+
local digest_nid = assert(objects.find_sigid_algs(sigid))
416+
signature = assert(objects.nid2table(digest_nid).sn)
412417
end
413418
cbind_data = assert(x509_digest(pem, signature))
414419
end

‎pgmoon/init.moon

+5
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,11 @@ class Postgres
414414
-- upgrade the signature if necessary (also handle the case of s/RSA-SHA1/sha256)
415415
if signature\match("^md5") or signature\match("^sha1") or signature\match("sha1$")
416416
signature = "sha256"
417+
else
418+
local objects = require("resty.openssl.objects")
419+
local sigid = assert objects.txt2nid(signature)
420+
local digest_nid = assert objects.find_sigid_algs(sigid)
421+
signature = assert objects.nid2table(digest_nid).sn
417422

418423
assert x509_digest(pem, signature)
419424

0 commit comments

Comments
 (0)
Please sign in to comment.