ArpePGSQL authentication
ArpePGSQL supports PostgreSQL password-family authentication (SCRAM-SHA-256, MD5, cleartext) on every platform, integrated authentication with Kerberos (GSSAPI) on Linux and SSPI on Windows, TLS, SCRAM channel binding, and optional GSS transport encryption. This page is the reference for the options and credential modes.
Authentication methods
| Method | Platform | Notes |
|---|---|---|
| SCRAM-SHA-256 | Linux, Windows | RFC 7677. Default for modern PostgreSQL (scram-sha-256 in pg_hba.conf) |
| SCRAM-SHA-256-PLUS | Linux, Windows (TLS) | SCRAM with RFC 5929 tls-server-end-point channel binding |
| MD5 | Linux, Windows | Legacy md5 auth method |
| password | Linux, Windows | Cleartext (password auth method) — only safe under TLS or gssencmode |
| Kerberos (GSSAPI) | Linux | A Kerberos ticket from the credential cache, a keytab or a principal and password; answers the server's gss method; mutual authentication always enforced. |
| Integrated (SSPI) | Windows | Logged-in Windows identity; the Kerberos package answers the server's gss method and Negotiate (Kerberos with NTLM fallback) its sspi method; mutual authentication always enforced. require_kerberos refuses an NTLM login, see NTLM |
The driver uses the method the server requests (from its pg_hba.conf);
you choose between password-family and
integrated auth via the options below.
Non-ASCII passwords: SCRAM uses the password bytes as-is; SASLprep (RFC 4013) normalisation is not applied. Printable-ASCII passwords (the common case) are unaffected. A password containing non-ASCII code points that the server normalised with
pg_saslprepwhen storing the verifier may fail to authenticate — use an ASCII password, or pre-normalise it to the same form the server stored.
Option / keyword reference
Options take a dotted form (adbc.arpepgsql.<key>) and a short form. The
two mean the same and are accepted both as database options
(AdbcDatabaseSetOption / db_kwargs) and as connection options
(AdbcConnectionSetOption / conn_kwargs), except trusted, which is
database only; database options are copied to the connection before the
session opens. The connection string also accepts ADO.NET-style keywords (e.g.
User ID, Password, Integrated Security). Full matrix in
Connection → Database-level vs connection-level keys.
| Option | Short form | Purpose |
|---|---|---|
adbc.arpepgsql.username / .password | username / password | SQL login credentials; when unset, taken from PGUSER / PGPASSWORD / ~/.pgpass (see PostgreSQL environment variables) |
adbc.arpepgsql.auth_type=integrated (or adbc.arpepgsql.trusted=true) | auth_mode, trusted (database only) | Enable integrated authentication: Kerberos on Linux, SSPI on Windows |
adbc.arpepgsql.sslmode | sslmode | disable / prefer (default) / require / verify-ca / verify-full |
adbc.arpepgsql.ssl_root_cert | ssl_root_cert | PEM root-CA file for verify-ca / verify-full, and for require, which then verifies the chain. Default: PGSSLROOTCERT, else ~/.postgresql/root.crt; with none, verify-ca refuses to connect and verify-full uses the system CA store (see TLS) |
adbc.arpepgsql.channel_binding | channel_binding | prefer (default) / require / disable; require accepts only a SCRAM-SHA-256-PLUS login (every other method is refused) |
adbc.arpepgsql.require_password_encryption | require_password_encryption | false (default) / true; refuse to send a cleartext or MD5 password over an unencrypted transport |
adbc.arpepgsql.krb5.ccache | krb5_ccache | Kerberos (Linux): credential cache file (default: the ambient cache from kinit). |
adbc.arpepgsql.krb5.keytab | krb5_keytab | Kerberos (Linux): keytab file, for service accounts. |
adbc.arpepgsql.krb5.principal + adbc.arpepgsql.krb5.password | krb5_principal, krb5_password | Kerberos (Linux): the driver obtains the ticket itself for this principal. |
adbc.arpepgsql.krb5.spn | krb5_spn | Use this SPN verbatim instead of the derived one |
adbc.arpepgsql.krbsrvname | krbsrvname | Replace the service part of the derived SPN (default postgres on Linux, POSTGRES on Windows) |
adbc.arpepgsql.gssencmode | gssencmode | disable (default) / prefer / require: GSS transport encryption (Linux). |
adbc.arpepgsql.require_kerberos | require_kerberos | Windows: refuse a login that did not negotiate Kerberos (default false), see NTLM. No effect on Linux. |
With integrated auth, set username to the PostgreSQL role to log in as (the
server checks that your Kerberos principal or Windows identity may use it); a
password is rejected.
import adbc_driver_manager.dbapi as dbapi
conn = dbapi.connect(driver="arpepgsql", db_kwargs={
"adbc.arpepgsql.server": "db.example.com",
"adbc.arpepgsql.username": "alice",
"adbc.arpepgsql.auth_type": "integrated",
"adbc.arpepgsql.sslmode": "verify-full",
})
Security — the default
sslmode=prefergives no MITM protection. Like libpq,preferfalls back to plaintext when the server declines TLS, and that reply is unauthenticated. On an untrusted network usesslmode=verify-fulland/orchannel_binding=require(which binds SCRAM to the TLS channel and refuses a PLUS-stripping downgrade).requireencrypts but does not verify the certificate unless a root certificate is set.
Kerberos authentication (Linux)
With auth_type=integrated (or trusted=true) the Linux driver logs in with
a Kerberos ticket through GSSAPI, against a gss line in pg_hba.conf.
MIT Kerberos is needed only for Kerberos. The driver loads on a host
without Kerberos, and password logins work there. A Kerberos login or a
gssencmode attempt needs libgssapi_krb5.so.2 and libkrb5.so.3; without
them it fails with a message naming the package to install: krb5-libs (RHEL, Rocky,
Fedora) or libgssapi-krb5-2 (Debian, Ubuntu).
Credential modes. The client ticket is acquired one of three ways,
selected by which krb5.* option is set:
- Ambient credential cache (default): the ticket from a prior
kinit, or the file named byKRB5CCNAMEorkrb5.ccache. - Keytab (
krb5.keytab): for service accounts that cannot run an interactivekinit.krb5.principaloptionally selects one principal of the keytab. - Principal and password (
krb5.principal+krb5.password): the driver obtains the ticket itself and keeps it in a private in-memory cache.krb5.passwordwithoutkrb5.principalis an error.
conn = dbapi.connect(driver="arpepgsql", db_kwargs={
"adbc.arpepgsql.server": "db.example.com",
"adbc.arpepgsql.database": "mydb",
"adbc.arpepgsql.username": "svc_etl",
"adbc.arpepgsql.auth_type": "integrated",
"adbc.arpepgsql.krb5.keytab": "/path/to/svc_etl.keytab",
})
- Service principal name. The target SPN defaults to
postgres/<server>(no port), as in libpq. Override the service part withkrbsrvname, or the whole SPN withkrb5.spn(for examplepostgres/db.example.com@EXAMPLE.COM). - Mutual authentication is always required: the driver refuses a server that reports success without completing the GSS exchange, and refuses password-family requests while integrated auth is active.
- Role. Set
adbc.arpepgsql.usernameto the PostgreSQL role. The server accepts it only if your Kerberos principal maps to that role (pg_hba.confoptions such asinclude_realm=0, or apg_ident.confmap). A password is rejected, andPGPASSWORD/ the password file are not read.
GSS transport encryption (gssencmode)
On Linux, gssencmode negotiates GSSAPI-level encryption before TLS and the
login:
| Value | Behaviour |
|---|---|
disable (default) | Never negotiate GSS encryption. This differs from libpq, whose default is prefer. |
prefer | Try GSS encryption; fall back to TLS or a plain connection when the server refuses it or no credentials are available. |
require | GSS encryption must succeed. TLS is skipped, and combining it with sslmode=require / verify-ca / verify-full is rejected. |
- When GSS encryption is active there is no TLS channel, so SCRAM channel binding is unavailable (plain SCRAM still runs inside the encrypted stream).
- The GSS context must grant confidentiality, mutual authentication, replay detection and sequence checking, or the connection is refused. Once established, any packet the GSS layer reports as replayed, out of order, stale or following a gap is a fatal error and the connection is dropped, as in libpq.
- On a host without MIT Kerberos,
preferconnects without GSS encryption andrequirefails. - The Windows driver has no GSS transport encryption:
requirefails there andpreferhas no effect.
Integrated authentication (Windows)
This section is about the Windows driver. On Linux, integrated authentication uses a Kerberos ticket: see Kerberos authentication (Linux).
On Windows the driver authenticates as the logged-in Windows user through
SSPI; no password, Kerberos configuration or ticket management is needed on
the client. The server side is a gss (or, on a Windows server, sspi) line
in pg_hba.conf. The driver picks the SSPI package as libpq
does: Kerberos for a gss line, Negotiate (Kerberos with NTLM fallback)
for an sspi line.
- Service principal name. The target SPN is
POSTGRES/<server>(no port), built from theservervalue as given. Connect by the fully qualified host name under which the SPN is registered, not by IP address or an alias. Override the service part withadbc.arpepgsql.krbsrvnamewhen the server runs under a different service name, or the whole SPN withadbc.arpepgsql.krb5.spn(for example when the SPN is registered under another host name);krb5.spnwins when both are set. - Mutual authentication is always required: the driver refuses a server that reports success without completing the exchange, and refuses password-family requests while integrated auth is active. If Windows does not report mutual authentication for the session, the login fails with "server did not provide mutual authentication"; registering the SPN and connecting by fully qualified host name lets Kerberos be used.
- Role. Set
adbc.arpepgsql.usernameto the PostgreSQL role. The server accepts it only if your Windows identity maps to that role (pg_hba.confoptions such asinclude_realm=0, or apg_ident.confmap). A password is rejected.
NTLM (Windows SSPI)
An sspi line in pg_hba.conf (a Windows server) makes the driver use the
Negotiate package, which falls back to NTLM when Kerberos is not possible:
the client or the server is not in a domain, no SPN is registered for the
PostgreSQL service account, no KDC is reachable, or the connection names the
server by IP address or by an alias the SPN does not match. A login over
loopback to a server on the same machine also negotiates NTLM. The driver
accepts such a login by default, as libpq does: Windows reports an NTLM
context as mutually authenticated, so it passes the driver's mutual
authentication check.
Kerberos also proves the server's identity to the client, through the SPN;
NTLM does not. To accept Kerberos only, set
adbc.arpepgsql.require_kerberos=true (require_kerberos as a short form and
in a URI query, RequireKerberos=yes in a connection string).
A login that negotiates anything else is then refused before the NTLM
exchange completes:
integrated auth: Windows integrated authentication: Negotiate fell back to
NTLM for SPN POSTGRES/db01. NTLM cannot authenticate the server and
require_kerberos is set, so the login was refused. Usual cause: no SPN
registered for the server, or no Kerberos KDC reachable. Register
POSTGRES/<server FQDN> for the PostgreSQL service account (setspn -S) and
connect by that name, or set krbsrvname or krb5_spn to the registered SPN
The SPN in the message is the one the driver asked for. Register it with
setspn -S POSTGRES/<fqdn> <service account> and connect by that fully
qualified name. If Windows does not report which package was negotiated, the
login is refused too under require_kerberos, and the message says the
package could not be determined. Like other refusals made by the driver during
login, this one has no SQLSTATE and returns ADBC_STATUS_IO.
A gss line uses the Kerberos package, which never falls back to NTLM. On
Linux the driver uses the Kerberos mechanism only, so require_kerberos has
no effect there.
Platform support
| Mode | Linux | Windows |
|---|---|---|
| SQL login (SCRAM/MD5/password) | ✓ | ✓ |
| TLS and SCRAM channel binding | ✓ | ✓ |
| Kerberos (GSSAPI: credential cache, keytab, principal and password) | ✓ (needs MIT Kerberos on the host) | — |
| Integrated (SSPI: Kerberos / Negotiate) | — | ✓ |
GSS transport encryption (gssencmode) | ✓ | — |
TLS
ArpePGSQL negotiates TLS the standard PostgreSQL way, before the login.
Direct TLS (PostgreSQL 17's sslnegotiation=direct) is not supported.
The options are in
Connection → TLS & encryption options.
Modes
sslmode | Encrypts | Checks the certificate | Checks the host name |
|---|---|---|---|
disable | no | — | — |
prefer (default) | if the server agrees | no | no |
require | yes | no (chain when a root certificate is set) | no |
verify-ca | yes | chain (a root certificate is required) | no |
verify-full | yes | chain | yes |
- Under
prefer, a server that declines TLS gets a plaintext session, and the driver prints a warning to standard error (or collects it, see Connection → Warnings). Once the server has agreed to TLS, a failed handshake is an error; there is no retry in clear. requirechecks the certificate chain when a root certificate is set (ssl_root_certorPGSSLROOTCERT), as libpq does; it then behaves asverify-ca. Without a root certificate setting,requireencrypts but checks nothing.~/.postgresql/root.crtis not read forrequire, so it does not turn verification on.verify-caneeds a root certificate (ssl_root_cert,PGSSLROOTCERTor~/.postgresql/root.crt). It refuses to connect without one, as libpq does: it checks no host name, so against the system CA store any certificate a public CA signed would pass.- Contradictory
encrypt/trust_server_cert/sslmodesettings are rejected, see Connection → Conflicting TLS settings. channel_binding=require(SCRAM-SHA-256-PLUS) ties the login to the server certificate and needs TLS. It accepts nothing else, as in libpq: a server that asks for a cleartext or MD5 password, for integrated (GSS / SSPI) authentication, or that lets the client in without authentication, is refused.gssencmode(GSS transport encryption) replaces TLS when it is active. It is available with the Linux driver, see GSS transport encryption; with the Windows driverrequirefails andpreferhas no effect.
Protocol versions
TLS 1.2 is the minimum and TLS 1.3 is used when the server offers it. There is
no ssl_min_protocol_version / ssl_max_protocol_version option.
The released binaries offer the hybrid post-quantum key exchange
X25519MLKEM768 first in TLS 1.3 and fall back to what the server supports.
What a connection negotiated can be read from the read-only options
adbc.arpepgsql.tls.version, adbc.arpepgsql.tls.group and
adbc.arpepgsql.tls.cipher, see
Connection → Read-only: negotiated TLS and OpenSSL version.
Independent of the host's TLS stack
Because the driver brings its own OpenSSL, the TLS versions it can use do not depend on the host. A server that only accepts TLS 1.3 works even where the host's own TLS stack has no TLS 1.3: for example Windows Server 2019 and older (Schannel), or a Linux host whose system OpenSSL is 1.0.x. The limit on Linux is the C library: the released binary needs glibc 2.28 or later (RHEL 8, Debian 10, Ubuntu 20.04 or newer), so RHEL 7 is not supported.
Where trusted certificates come from
ArpePGSQL carries its own OpenSSL (the 3.5 LTS series) and
never uses the operating system's TLS stack. The version in a
deployed driver can be read from the adbc.arpepgsql.openssl_version database
option. For verify-ca / verify-full, the CAs come from, in this order:
ssl_root_cert(a PEM file; it may hold several certificates);- the
PGSSLROOTCERTenvironment variable; - the default file
~/.postgresql/root.crt(Windows:%APPDATA%\postgresql\root.crt), when it exists, as in libpq; - for
verify-fullonly, the operating system's CA store.verify-carefuses to connect instead.
sslrootcert=system is taken as a file name.
The system CA store is read as follows:
| Client OS | verify-full without a root certificate |
|---|---|
| Linux | OpenSSL's default paths, plus the first distribution CA bundle found: /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem (RHEL, Fedora), /etc/pki/tls/certs/ca-bundle.crt, /etc/ssl/certs/ca-certificates.crt (Debian, Ubuntu, Alpine), /etc/ssl/ca-bundle.pem (SUSE), /etc/ssl/cert.pem. Setting SSL_CERT_FILE or SSL_CERT_DIR replaces the bundle probe with that file or directory. |
| Windows | The machine's trusted root certificates (the ROOT certificate store). SSL_CERT_FILE / SSL_CERT_DIR are not used. |
A server whose certificate is signed by a private CA always needs
ssl_root_cert. Managed services (AWS RDS, Azure Database for PostgreSQL,
Google Cloud SQL, …) publish their CA bundles: download yours and pass it as
ssl_root_cert.
Host name check and SNI
With verify-full, the server name must match the certificate: a DNS name
against its DNS SANs (or its CN when it has none), an IP address against its IP
SANs. A wildcard must be the whole first label (*.example.com). Always set
the server explicitly: when no server is set, the driver connects to
localhost, checks the certificate against localhost and
sends it as SNI.
SNI carries the server name and cannot be turned off; it is not
sent when the server is an IP address (RFC 6066).
Client certificates
Not supported: sslcert / sslkey do not exist, and the cert
authentication method cannot be used.
OpenSSL configuration
Like any OpenSSL 3 program, the driver reads an OpenSSL configuration file at
the first TLS connection: the file named by OPENSSL_CONF, else
/etc/ssl/openssl.cnf on Linux. Settings there, such as cipher lists or the
security level, apply. The driver's TLS 1.2 minimum always wins. RHEL's system
crypto-policies live under /etc/pki/tls/openssl.cnf, so they apply only if
that file is the one loaded (for example with
OPENSSL_CONF=/etc/pki/tls/openssl.cnf).
TLS errors are listed under Troubleshooting → TLS / certificates.