Skip to content

Commit

Permalink
Fix ssl test by copying root client-side certificates. (#893)
Browse files Browse the repository at this point in the history
It seems that Postgres 14 implement more security checks around ownership of
the client-side root certificate, and our symlink doesn't comply with those
rules anymore in the GitHub Action environment.
  • Loading branch information
DimCitus committed May 12, 2022
1 parent bf07407 commit 753d334
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
17 changes: 16 additions & 1 deletion tests/test_enable_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,22 @@ def test_010_enable_ssl_verify_ca_monitor():
print("%s" % p.stdout)

# the root user also needs the certificates, tests are connecting with it
subprocess.run(["ln", "-s", client_top_directory, "/root/.postgresql"])
root_top_directory = "/root/.postgresql"
p = subprocess.run(
["sudo", "install", "-d", "-m", "740", root_top_directory]
)
assert p.returncode == 0

p = subprocess.run(
[
"sudo",
"cp",
clientCert.crt,
clientCert.csr,
clientCert.key,
root_top_directory,
]
)
assert p.returncode == 0

p = subprocess.run(
Expand Down
27 changes: 23 additions & 4 deletions tests/test_ssl_cert.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,34 @@ def test_000_create_monitor():
)
serverCert.create_signed_certificate(cluster.cert)

# the root user also needs the certificates, tests are connecting with it
root_top_directory = "/root/.postgresql"
p = subprocess.run(
["sudo", "install", "-d", "-m", "740", root_top_directory]
)
assert p.returncode == 0

p = subprocess.run(
[
"sudo",
"cp",
clientCert.crt,
clientCert.csr,
clientCert.key,
root_top_directory,
]
)
assert p.returncode == 0

p = subprocess.run(
[
"ls",
"-ld",
client_top_directory,
root_top_directory,
os.path.join(root_top_directory, "postgresql.crt"),
os.path.join(root_top_directory, "postgresql.csr"),
os.path.join(root_top_directory, "postgresql.key"),
cluster.cert.crt,
cluster.cert.csr,
cluster.cert.key,
Expand All @@ -112,10 +135,6 @@ def test_000_create_monitor():
)
print("%s" % p.stdout)

# the root user also needs the certificates, tests are connecting with it
subprocess.run(["ln", "-s", client_top_directory, "/root/.postgresql"])
assert p.returncode == 0

#
# Now create the monitor Postgres instance with the certificates
#
Expand Down

0 comments on commit 753d334

Please sign in to comment.