Connect Liquibase to Oracle Database with Kerberos Authentication
Last updated: March 24, 2026
This procedure configures Liquibase to authenticate to Oracle Database using Kerberos (GSSAPI) over a standard TCP connection. Kerberos authentication and TLS encryption are independent.
Before you begin
Important: Java 23 or earlier is required. Java 24 permanently removed the JVM API (Subject.getSubject) that Oracle JDBC depends on for Kerberos authentication (JEP 486).
Ask your Oracle DBA to configure the Oracle server’s sqlnet.ora for Kerberos, register the database service principal with the KDC, and provide you with a keytab file for the Liquibase service account. The server’s sqlnet.ora must include SQLNET.AUTHENTICATION_KERBEROS5_SERVICE = oracle; without this setting, connections fail with ORA-12641.
Ask your Oracle DBA to create an external database user mapped to the Kerberos principal:
CREATE USER liquibase_svc IDENTIFIED EXTERNALLY AS 'liquibase-svc@MYCOMPANY.COM'; GRANT CREATE SESSION TO liquibase_svc;Ask your KDC administrator for: the Kerberos realm name, KDC hostname, and domain realm mapping.
Procedure
Download Oracle JDBC driver
All JARs are available from the Oracle JDBC Downloads page and Maven Central. Replace 21.13.0.0 with the latest 21.x release.
Download the following JARs from the Oracle JDBC Downloads page and place them in your lib/ directory.
ojdbc11.jar— required for all configurationsoraclepki.jar,osdt_core.jar,osdt_cert.jar— required for TCPS (Part B) only
Configure Oracle server for Kerberos (ask your DBA)
Ask your Oracle DBA to add the following lines to $ORACLE_HOME/network/admin/sqlnet.ora on the Oracle DB server.
After editing, restart the Oracle listener.
lsnrctl stop && lsnrctl startConfigure Kerberos
Create krb5.conf with your Kerberos realm configuration.
Be sure to:
Replace
your_realmwith your Kerberos realm name (typically uppercase). For example,MYCOMPANY.COM,CORP.EXAMPLE.COMReplace
your_kdc_hostwith your KDC hostname. For example,kdc.mycompany.com,kdc1.corp.example.comReplace
your_domainwith your domain for realm mapping. For example,mycompany.com,corp.example.com
Create sqlnet.ora
Create sqlnet.ora in your working directory to enable Kerberos authentication.
Be sure to:
Replace
your_krb5_conf_pathwith the absolute path to your krb5.conf file. For example,/absolute/path/to/liquibase-krb/krb5.confReplace
your_keytab_pathwith the absolute path to your Kerberos keytab file. For example,/absolute/path/to/liquibase.keytabReplace
your_cc_namewith the path for the Kerberos credential cache. For example,/tmp/krb5cc_liquibase
Create tnsnames.ora
Create tnsnames.ora in your TNS admin directory.
Be sure to:
Replace
your_tns_aliaswith your TNS alias. For example,MYDB,PROD_DB,ORA_KRBReplace
your_hostnamewith your Oracle server hostname. For example,your-db-host.example.com,db.company.comReplace
your_portwith your Oracle DB port. Usually. For example,1521Replace
your_service_namewith your service name. For example,MYDB,ORCL
Configure JDBC properties
Create ojdbc.properties in your TNS admin directory.
Be sure to:
Replace
your_tns_admin_dirwith your absolute path to your TNS admin directory. For example,/home/user/tns-admin,/Users/name/tns-adminReplace
your_cc_namewith your path for the Kerberos credential cache (must match sqlnet.ora). For example,/tmp/krb5cc_liquibaseReplace
your_keytab_pathwith your path to your Kerberos keytab file (must match sqlnet.ora). For example,/etc/liquibase.keytab
Configure Liquibase
Create liquibase.properties in your working directory. The /@MYDB URL format (with no username/password before @) means "connect using external authentication" — the Kerberos ticket provides the credentials.
Be sure to:
Replace
MYDBwith your TNS alias from tnsnames.ora. For example,MYDB,PROD_DBReplace
liquibase-svcwith your Kerberos principal (without realm). For example,liquibase-svc,lbsvc
Set environment variables
Set the following environment variables before running Liquibase.
Be sure to:
Replace
your_krb5_conf_pathwith the absolute path to your krb5.conf file. For example,/absolute/path/to/liquibase-krb/krb5.confReplace
your_ojdbc_props_pathwith the absolute path to your ojdbc.properties file. For example,/absolute/path/to/liquibase-krb/ojdbc.properties
Obtain Kerberos ticket
Before running Liquibase, obtain a valid Kerberos ticket (TGT). Choose the method that matches your environment.
Be sure to:
Replace
your_username@your_realmwith your Kerberos principal. For example,liquibase-svc@COMPANY.COMReplace
your_krb5_confwith the absolute path to your krb5.conf file (Headless only). For example,/absolute/path/to/liquibase-krb/krb5.confReplace
your_keytab_pathwith the absolute path to your keytab file (Headless only). For example,/absolute/path/to/liquibase.keytabReplace
your_cc_namewith the path for the credential cache. For example,/tmp/krb5cc_liquibase
kinit your_username@your_realmVerify the ticket was obtained.
Set the credential cache environment variable so tools find it automatically.
Run Liquibase (TCP)
Be sure to:
Replace
your_krb5_conf_pathwith the absolute path to your krb5.conf file. For example,/absolute/path/to/liquibase-krb/krb5.confReplace
your_ojdbc_props_pathwith the absolute path to your ojdbc.properties file. For example,/absolute/path/to/liquibase-krb/ojdbc.propertiesReplace
your_liquibase_krb_pathwith the absolute path to your working directory. For example,/absolute/path/to/liquibase-krb
Get the server's TLS certificate
If your DBA provides a PEM file for the Oracle server certificate, copy it to your working directory and skip to the next step.
Otherwise, extract it from the Oracle TLS port.
Be sure to:
Replace
db.company.comwith your Oracle DB hostnameReplace
2484with your Oracle TCPS port. Usually,2484
Create the wallet directory
Create the wallet directory inside your working directory.
mkdir -p walletImport the certificate into the wallet
Import the server certificate into the wallet. Use whichever approach is available on your system.
Verify the wallet contents (optional but recommended)
If you have oraclepki.jar available, compile and run this one-time diagnostic to confirm the wallet has the server certificate.
Expected output:
Checking: wallet/cwallet.sso
Entries: 1
CN=db.company.com
Subject: CN=db.company.comIf Entries: 0, the wallet is empty — re-run the previous step.
Update tnsnames.ora for TCPS
Add a TCPS entry to your existing tnsnames.ora. Keep the original TCP entry (MYDB) as a fallback.
Be sure to:
Replace
db.company.comwith your Oracle DB hostnameReplace
MYDBwith your Oracle service nameReplace
/absolute/path/to/walletwith the absolute path to your wallet directory
Create ojdbc_ssl.properties
Create ojdbc_ssl.properties as a separate file from ojdbc.properties. This lets you switch between TCP and TCPS without editing the same file — use ojdbc.properties for TCP and ojdbc_ssl.properties for TCPS.
Be sure to:
Replace
/absolute/path/to/liquibase-krbwith the absolute path to your working directoryReplace
/absolute/path/to/liquibase.keytabwith the absolute path to your keytab fileReplace
/absolute/path/to/walletwith the absolute path to your wallet directorySet
oracle.net.ssl_server_dn_match=trueif the server cert CN matches the hostname in your JDBC URL; set it tofalseif connecting via localhost, IP, or alias
Run Liquibase with TCPS
The only changes from the TCP run are:
Use
ojdbc_ssl.propertiesinstead ofojdbc.propertiesAdd the three PKI JARs to the classpath
Use the
MYDB_SSLTNS alias (TCPS, port 2484)
Be sure to:
Replace
your_krb5_conf_pathwith the absolute path to your krb5.conf fileReplace
your_liquibase_krb_pathwith the absolute path to your working directory