Skip to content

SSL and Security

Use this page when PostgreSQL requires TLS or custom certificate material. PGStyx exposes the standard TLS settings through write options.

df.write
.format("pgstyx")
.option("url", "jdbc:postgresql://host:5432/warehouse")
.option("dbtable", "events")
.option("user", "postgres")
.option("password", "secret")
.option("ssl", "true")
.option("sslMode", "verify-full")
.save()

ssl=true with an sslMode value is the minimum working TLS configuration.

ModeBehavior
disableNo TLS. Connection fails if the server requires it.
allowTLS only if the server insists.
preferTLS preferred; falls back to plaintext if unavailable.
requireTLS always. No server identity check.
verify-caTLS plus certificate-chain validation.
verify-fullverify-ca plus hostname validation.

Use verify-full whenever traffic crosses an untrusted network.

Use these options when the environment cannot rely on default trust stores.

df.write
.format("pgstyx")
.option("url", "jdbc:postgresql://host:5432/warehouse")
.option("dbtable", "events")
.option("user", "postgres")
.option("password", "secret")
.option("ssl", "true")
.option("sslMode", "verify-full")
.option("sslRootCert", "/etc/pgstyx/root.crt")
.option("sslCert", "/etc/pgstyx/client.crt")
.option("sslKey", "/etc/pgstyx/client.key")
.save()

Certificate files must exist at the same path on every worker, not just on the machine that starts the job. On Databricks, use init scripts or a mounted volume. On EMR and Dataproc, stage the files through the cluster bootstrap path.

sslKey expects a DER-encoded PKCS#8 private key. Convert PEM keys with:

Terminal window
openssl pkcs8 -topk8 -inform PEM -outform DER -in key.pem -out key.der -nocrypt

PGStyx expects the resolved database password as the value of password. If your environment uses a secret manager, fetch the secret before you construct the write options:

val password = dbutils.secrets.get(scope = "warehouse", key = "pgstyx_password")
df.write
.format("pgstyx")
.option("password", password)
// ...
.save()
CapabilityTier
No TLS (ssl=false)Community
ssl=true with any sslModePro
sslCert, sslKey, or sslRootCert with ssl=trueEnterprise

sslCert, sslKey, and sslRootCert are ignored when ssl=false.