Skip to main content

ArpeMSSQL authentication

ArpeMSSQL supports the same SQL Server connection modes as FastBCP:

ModeHow to request it
SQL loginusername + password (structured options or User ID=/Password= in a connection string)
Trusted / integrated (Windows and Linux)adbc.arpemssql.trusted=true (or =sspi), or Integrated Security=SSPI / Trusted_Connection=yes in a connection string
Full connection stringadbc.arpemssql.connection_string=... — the escape hatch

ArpeMSSQL is the driver (native TDS, no client library underneath), so the "full connection string" is parsed by ArpeMSSQL, not passed through to another driver. It can only honor modes ArpeMSSQL implements; anything else fails fast (see below).

For Microsoft Entra ID (Azure SQL, Microsoft Fabric), see Connection → Azure SQL, Microsoft Fabric & Entra ID. Entra ID can also be selected with Authentication= in a connection string, see Connection → Entra ID in a connection string.

Option / keyword reference​

Structured ADBC options:

  • adbc.arpemssql.trusted — true/sspi/yes/1 → integrated; false/no/0 → SQL.
  • adbc.arpemssql.auth_type — sql/SqlPassword | integrated/sspi/trusted | ActiveDirectoryDefault/default (Entra ID default credential chain, see Connection). The other Entra ID / certificate families are recognized and rejected with NOT_IMPLEMENTED.
  • adbc.arpemssql.require_kerberos — true refuses a Windows integrated login that fell back to NTLM (connection string RequireKerberos; default false). See NTLM fallback. Since v0.7.6.

Kerberos options, each a structured ADBC option with its connection-string keyword(s). They are only read under integrated auth and ignored by SQL login. On Windows, SSPI always uses the logged-in session, so only the SPN override applies there. All are optional.

Structured optionConnection-string keyword(s)Selects
adbc.arpemssql.krb5.keytabKrb5 Keytab File (Krb5KeytabFile, krb5-keytabfile)keytab credential mode (Linux)
adbc.arpemssql.krb5.principalKrb5 Principal (Krb5Principal)explicit client principal (Linux)
adbc.arpemssql.krb5.passwordKrb5 Password (Krb5Password)password credential mode, with a principal (Linux)
adbc.arpemssql.krb5.ccacheKrb5 Credential Cache (Krb5CredentialCache, krb5-credcachefile)per-connection credential cache path (Linux)
adbc.arpemssql.krb5.spnService Principal Name (ServicePrincipalName, service_principal_name)SPN override, Windows and Linux; see SPN

Authenticator=krb5/winsspi/sspi is a pyodbc-style alias for integrated auth; Authenticator=sql forces SQL login.

Connection-string auth-mode keywords (case-insensitive; aliases of the same auth-mode field, so specifying two is a duplicate-key error):

  • Integrated Security — SSPI/true/yes/1 → integrated; false/no/0 → SQL.
  • Trusted_Connection (also Trusted Connection) — SSPI/yes/true/1 → integrated; no/false/0 → SQL.
  • Authentication — SqlPassword (or Sql Password) → SQL. ActiveDirectoryDefault, ActiveDirectoryServicePrincipal and ActiveDirectoryManagedIdentity (alias ActiveDirectoryMSI) → Entra ID; see Connection → Entra ID in a connection string. The other ActiveDirectory* values (Integrated, Password, Interactive, DeviceCodeFlow, WorkloadIdentity) are rejected with NOT_IMPLEMENTED (use Integrated Security=SSPI for Kerberos).
Version

Entra ID through Authentication= (and the URI fedauth parameter) since ArpeMSSQL v0.7.5. Earlier versions rejected every ActiveDirectory* value with NOT_IMPLEMENTED.

Mutual exclusion: integrated/trusted auth cannot be combined with a SQL username/password. Doing so fails with INVALID_ARGUMENT before any socket is opened. The Kerberos Krb5 Password is a separate field, used only to get a Kerberos ticket: it is not the SQL Password and does not trip this check.

Credential modes (Linux Kerberos)​

On Linux the driver gets the Kerberos credential in one of three ways, chosen by which options are set, in this order of precedence:

  1. keytab — a keytab is set (Krb5 Keytab File). For service accounts and unattended jobs.
  2. password — both Krb5 Principal and Krb5 Password are set. The driver gets a ticket into a private in-memory credential cache; it does not touch the ambient cache. Krb5 Password without Krb5 Principal fails with INVALID_ARGUMENT.
  3. ccache (default) — none of the above: the ambient credential cache (a prior kinit, or KRB5CCNAME; Krb5 Credential Cache overrides the path).
Python
import adbc_driver_manager.dbapi as dbapi

# ccache mode: run `kinit user@EXAMPLE.COM` first
conn = dbapi.connect(driver="arpemssql", db_kwargs={
"adbc.arpemssql.connection_string":
"Server=sql.example.com;Database=mydb;Integrated Security=SSPI;Encrypt=true",
})

# keytab mode
conn = dbapi.connect(driver="arpemssql", db_kwargs={
"adbc.arpemssql.server": "sql.example.com",
"adbc.arpemssql.database": "mydb",
"adbc.arpemssql.trusted": "true",
"adbc.arpemssql.krb5.keytab": "/etc/security/keytabs/etl.keytab",
"adbc.arpemssql.krb5.principal": "etl@EXAMPLE.COM",
"adbc.arpemssql.encrypt": "true",
})

Platform support​

Trusted / integrated authentication is available on Windows and Linux:

  • Windows (x64) — SSPI, the "Negotiate" package: Kerberos, with NTLM fallback, the same mechanism as Microsoft's ODBC driver and Microsoft.Data.SqlClient. The driver authenticates as the logged-in Windows user; no username, password or ticket setup is needed. adbc.arpemssql.require_kerberos refuses an NTLM login; see NTLM fallback.
  • Linux (x64) — GSSAPI/SPNEGO through MIT Kerberos, with the three credential modes above (they need MIT Kerberos 1.11 or later). The driver does not link Kerberos: the first Kerberos login loads libgssapi_krb5.so.2 and libkrb5.so.3, from the package krb5-libs (RHEL, Rocky, Fedora) or libgssapi-krb5-2 (Debian, Ubuntu). The driver therefore still loads on a host without Kerberos; only a Kerberos login there fails, with "Kerberos integrated authentication needs MIT Kerberos, which was not found (…). Install krb5-libs (RHEL, Rocky, Fedora) or libgssapi-krb5-2 (Debian, Ubuntu)". SQL login and Entra ID keep working.
Version

Kerberos in the Linux release binary since ArpeMSSQL v0.7.5. Earlier Linux releases refused integrated auth and ignored the krb5.* options.

With Kerberos the server's identity is always verified (mutual authentication): the login fails unless the server proves it, so the SQL Server SPN must be registered and the server reached by its fully qualified name.

Large Kerberos tokens (users in many AD groups) are handled: the login succeeds regardless of token size.

Service principal name (SPN)​

With Kerberos, the SPN the driver requests must match the one registered in Active Directory for the SQL Server service account. By default the driver derives it as MSSQLSvc/<host>:<port>:

  • The host is used verbatim (no DNS rewrite): connect by the FQDN the SPN is registered for, not a short name, alias or IP address.
  • For a named instance (host\INSTANCE, see Named instances) the port is the one resolved from the SQL Server Browser — the dynamic port SQL Server registers at startup, not 1433. The instance name never appears in the SPN.

If the registered SPN differs (for example a load-balancer or alias name), set adbc.arpemssql.krb5.spn (or Service Principal Name= in a connection string) to the exact SPN; the override applies to both Windows SSPI and Linux Kerberos. On Windows, a short name, alias or IP address often falls back to NTLM (accepted unless require_kerberos is set, see NTLM fallback), while the FQDN gives Kerberos. The raw SSPI or GSSAPI error is surfaced to help diagnose MSSQLSvc/... mismatches.

NTLM fallback​

On Windows, Negotiate 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 SQL Server service, or the connection names the server by IP address or by an alias the SPN does not match. The driver accepts such a login, as the Microsoft ODBC driver and Microsoft.Data.SqlClient do.

Kerberos also proves the server's identity to the client, through the SPN; NTLM does not. To accept Kerberos only, set adbc.arpemssql.require_kerberos=true (RequireKerberos=yes in a connection string; default false). A login that negotiates anything else is then refused:

Windows integrated authentication negotiated NTLM, not Kerberos, and
adbc.arpemssql.require_kerberos is set, so the login was refused. Connect by
the server's fully qualified name, with the SPN MSSQLSvc/<host>:<port>
registered for the SQL Server service account (or set adbc.arpemssql.krb5.spn
to the registered SPN)

Register the SPN with setspn -S MSSQLSvc/<fqdn>:<port> <service account>. A login over loopback to a server on the same machine negotiates NTLM, so it is refused under require_kerberos too. On Linux the driver only does Kerberos, and the option has no effect.

Version

Since ArpeMSSQL v0.7.6.

Checking the result​

On a domain-joined Windows host, connect with Server=<FQDN>;Database=<db>;Integrated Security=SSPI; (no User ID/Password). On Linux, use the same connection string after kinit (or with a keytab or password mode). Then:

  • SELECT SUSER_SNAME() returns your domain account.
  • SELECT auth_scheme FROM sys.dm_exec_connections WHERE session_id=@@SPID reports KERBEROS (NTLM if Windows fell back to NTLM).

TLS​

By default (TDS 7.4) ArpeMSSQL negotiates encryption in the TDS PRELOGIN exchange, then runs the TLS handshake inside TDS packets. With tds_version=8.0 (or Encrypt=Strict) it uses TDS 8.0 strict encryption instead, where TLS starts before any TDS traffic; see Strict encryption (TDS 8.0). The options are in Connection → Encryption / TLS.

What gets encrypted​

encrypt takes true/false (also 1/0, yes/no, and SqlClient's Mandatory/Optional). Strict selects TDS 8.0.

SettingServer encryption settingResult
tds_version=8.0 / Encrypt=StrictanyFull TLS from the first byte; the certificate is always checked.
encrypt=false (default)offLogin-only TLS: the login packet (with the password) is encrypted, then the session continues in clear. The certificate is not checked.
encrypt=falseforced (Force Encryption)Full TLS, and the certificate is checked (unless trust_server_cert=true).
encrypt=trueoff or forcedFull TLS with certificate and host name checks (unless trust_server_cert=true). If the server refuses encryption, the connection fails.
Entra ID (federated) loginanyAlways full TLS.

If the server supports no encryption at all, a SQL login is refused rather than sent in clear, unless allow_cleartext_login=true. A server that forces encryption with a self-signed certificate therefore needs its certificate trusted with tls_ca_file (or TrustServerCertificate=true) even when you did not ask for encrypt.

Strict encryption (TDS 8.0)​

A server with Force Strict Encryption on (SQL Server 2022 and newer, Azure SQL) refuses the TDS 7.4 login, where TLS is negotiated inside the cleartext PRELOGIN; the connection fails with "Failed to receive Pre-Login response", and the error points to tds_version=8.0. With tds_version=8.0 (or Encrypt=Strict, the spelling used by SqlClient, ODBC 18 and JDBC):

  • the TLS handshake comes first, on the TCP connection, offering ALPN tds/8.0 and SNI; PRELOGIN and LOGIN7 then travel inside TLS 1.2 or 1.3;
  • the server certificate is always verified: trust_server_cert=true is refused, as Microsoft's drivers ignore TrustServerCertificate there. For a private CA or a self-signed certificate, trust it with tls_ca_file (ServerCertificate), and set host_name_in_certificate if it names another host;
  • encryption is implied, so encrypt does not apply.

A server that does not enforce strict encryption accepts it too, if its certificate verifies. The default stays 7.4.

SpellingValues
adbc.arpemssql.tds_version7.4 (default), 8.0 / 8
Connection string TDS Version, TDSVersionsame
Connection string / option Encrypt=Strict= 8.0 (conflicts with TDS Version=7.4)
URI ?tds_version=8.0, ?encrypt=strictsame
Python
import adbc_driver_manager.dbapi as dbapi

conn = dbapi.connect(driver="arpemssql", db_kwargs={
"adbc.arpemssql.connection_string":
"Server=sql.corp.example;Database=mydb;User ID=etl;Password=<password>;"
"Encrypt=Strict;ServerCertificate=/etc/ssl/corp-ca.pem",
})
Version

Since ArpeMSSQL v0.7.5.

Protocol versions​

TLS 1.2 is the minimum and TLS 1.3 is used when the server offers it. The minimum is fixed: there is no option to allow TLS 1.0 / 1.1, so SQL Server versions that cannot do TLS 1.2 cannot be reached with encryption.

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​

ArpeMSSQL carries its own copy of OpenSSL 3, linked into the library (the Linux release is built with OpenSSL 3.6.4). It does not use the operating system's TLS stack, but it does trust the operating system's certificates:

  • Windows — the machine's trusted root store. OpenSSL's default location is not trusted.
  • Linux — the distribution's CA bundle, the first found of /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem, /etc/pki/tls/certs/ca-bundle.crt, /etc/ssl/certs/ca-certificates.crt, /etc/ssl/ca-bundle.pem and /etc/ssl/cert.pem. This covers RHEL, Rocky, AlmaLinux, Debian, Ubuntu and SUSE without any setting. Setting the SSL_CERT_FILE (a PEM bundle) or SSL_CERT_DIR (a hashed directory) environment variable replaces that bundle.

The same store verifies the Entra ID sign-in service (login.microsoftonline.com) when the driver fetches a token.

To verify a server whose certificate is not publicly trusted, rather than turning verification off, trust its CA (or the server's own self-signed certificate) with adbc.arpemssql.tls_ca_file (connection-string ServerCertificate, URI certificate): a PEM file trusted in addition to the system store.

Python
import adbc_driver_manager.dbapi as dbapi

conn = dbapi.connect(driver="arpemssql", db_kwargs={
"adbc.arpemssql.connection_string":
"Server=sql.corp.example;Database=mydb;User ID=etl;Password=<password>;"
"Encrypt=true;ServerCertificate=/etc/ssl/corp-ca.pem;"
"HostNameInCertificate=sql.corp.example",
})

trust_server_cert=true skips the check entirely; keep it for development servers. It is refused with TDS 8.0 strict encryption.

Version

tls_ca_file and the Windows trusted root store since ArpeMSSQL v0.7.0; the Linux distribution CA bundle (and the Windows store for the Entra ID sign-in) since ArpeMSSQL v0.7.3. Earlier versions trusted only OpenSSL's default locations, which hold no CAs on RHEL and Windows.

Host name check and SNI​

With the certificate check on, the host name from Server (without the port or instance 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). When the certificate names another host (an alias, a load balancer, a self-signed SSL_Self_Signed_Fallback certificate), set adbc.arpemssql.host_name_in_certificate (connection-string HostNameInCertificate, URI hostNameInCertificate) to the name, or IP address, the certificate carries. SNI is sent for DNS names, not for IP addresses.

Version

host_name_in_certificate since ArpeMSSQL v0.7.0.

Client certificates​

Not supported: the driver presents no client certificate.

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.