We're trying to connect to an Azure Database for PostgreSQL flexible server from Databricks using the jdbc driver org.postgresql.Driver.
Since the flexible server enforces SSL, we added the ssl and sslmode options to our existing code:
driver = "org.postgresql.Driver"
url = "jdbc:postgresql://<server>/<db>"
user = "<user>"
password = "<password>"
query = "<someQuery>"
remote_table = spark.read.format("jdbc") \
.option("driver", driver) \
.option("url", url) \
.option("user", user) \
.option("password", password) \
.option("query", query) \
.option("ssl", True) \
.option("sslmode", "require" ) \
.load()
The error we get is
org.postgresql.util.PSQLException: SSL error: Received fatal alert: handshake_failure
How do we establish an SSL connection to our Postgres using the above code? Any help would be greatly appreciated.
We know this can be done using psycopg2 and sslmode="require" (and did so successfully in a separate notebook in order to verify that our password is correct and the firewall is configured accordingly), but we'd really prefer to integrate the process into our existing solution with as little changes as possible.
Thanks in advance.


