Skip to content

Commit e65af32

Browse files
Gabor Simkoleafo
authored andcommitted
Add support for X509 signature algorithms such as RSA-SHA1 and ECDSA-with-SHA384
1 parent 248f5c3 commit e65af32

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

pgmoon/init.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,12 @@ do
402402
pem, signature = server_cert:pem(), server_cert:getsignaturename()
403403
end
404404
signature = signature:lower()
405-
if signature:match("^md5") or signature:match("^sha1") then
405+
local _, with_sig
406+
_, _, with_sig = signature:find("%-with%-(.*)")
407+
if with_sig then
408+
signature = with_sig
409+
end
410+
if signature:match("^md5") or signature:match("^sha1") or signature:match("sha1$") then
406411
signature = "sha256"
407412
end
408413
cbind_data = assert(x509_digest(pem, signature))

pgmoon/init.moon

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,13 @@ class Postgres
406406

407407
signature = signature\lower!
408408

409-
-- upgrade the signature if necessary
410-
if signature\match("^md5") or signature\match("^sha1")
409+
-- Handle the case when the signature is e.g. ECDSA-with-SHA384
410+
_, _, with_sig = signature\find("%-with%-(.*)")
411+
if with_sig
412+
signature = with_sig
413+
414+
-- upgrade the signature if necessary (also handle the case of s/RSA-SHA1/sha256)
415+
if signature\match("^md5") or signature\match("^sha1") or signature\match("sha1$")
411416
signature = "sha256"
412417

413418
assert x509_digest(pem, signature)

spec/docker_enable_ssl.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ls -lah >&2
1111
openssl req -new -passout pass:itchzone -text -out server.req -subj "/C=US/ST=Leafo/L=Leafo/O=Leafo/CN=itch.zone"
1212
openssl rsa -passin pass:itchzone -in privkey.pem -out server.key
1313
rm privkey.pem
14-
openssl req -x509 -in server.req -text -key server.key -out server.crt
14+
openssl req -x509 -sha1 -in server.req -text -key server.key -out server.crt
1515
chmod og-rwx server.key
1616

1717
# TLSv1 min version to mimic older versions of postgres

spec/pgmoon_spec.moon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ describe "pgmoon with server", ->
174174
errors = {
175175
"timeout": true
176176
"Connection timed out": true
177+
"Operation timed out": true
177178
}
178179

179180
assert.true errors[err]

spec/postgres.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function makecerts {
1414
openssl req -new -passout pass:itchzone -text -out server.req -subj "/C=US/ST=Leafo/L=Leafo/O=Leafo/CN=itch.zone"
1515
openssl rsa -passin pass:itchzone -in privkey.pem -out server.key
1616
rm privkey.pem
17-
openssl req -x509 -in server.req -text -key server.key -out server.crt
17+
openssl req -x509 -sha1 -in server.req -text -key server.key -out server.crt
1818
chmod og-rwx server.key
1919
)
2020
}

0 commit comments

Comments
 (0)