Skip to content

Commit 00807b9

Browse files
Add explicit check for SSL certificate
1 parent fecb33c commit 00807b9

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

python/psycopg/src/example.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@ def create_connection(cluster_user, cluster_endpoint, region):
1414
else:
1515
password_token = client.generate_db_connect_auth_token(cluster_endpoint, region)
1616

17+
ssl_cert_path = "./root.pem"
18+
if not os.path.isfile(ssl_cert_path):
19+
raise FileNotFoundError(f"SSL certificate file not found: {ssl_cert_path}")
20+
1721
conn_params = {
1822
"dbname": "postgres",
1923
"user": cluster_user,
2024
"host": cluster_endpoint,
2125
"port": "5432",
2226
"sslmode": "verify-full",
23-
"sslrootcert": "./root.pem",
27+
"sslrootcert": ssl_cert_path,
2428
"password": password_token
2529
}
2630

0 commit comments

Comments
 (0)