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

1

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 configurations

  • oraclepki.jar, osdt_core.jar, osdt_cert.jar — required for TCPS (Part B) only

loading

loading
2

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.

loading

After editing, restart the Oracle listener.

lsnrctl stop && lsnrctl start
3

Configure Kerberos

Create krb5.conf with your Kerberos realm configuration.

Be sure to:

  • Replace your_realm with your Kerberos realm name (typically uppercase). For example, MYCOMPANY.COM, CORP.EXAMPLE.COM

  • Replace your_kdc_host with your KDC hostname. For example, kdc.mycompany.com, kdc1.corp.example.com

  • Replace your_domain with your domain for realm mapping. For example, mycompany.com, corp.example.com

loading
4

Create sqlnet.ora

Create sqlnet.ora in your working directory to enable Kerberos authentication.

Be sure to:

  • Replace your_krb5_conf_path with the absolute path to your krb5.conf file. For example, /absolute/path/to/liquibase-krb/krb5.conf

  • Replace your_keytab_path with the absolute path to your Kerberos keytab file. For example, /absolute/path/to/liquibase.keytab

  • Replace your_cc_name with the path for the Kerberos credential cache. For example, /tmp/krb5cc_liquibase

loading
5

Create tnsnames.ora

Create tnsnames.ora in your TNS admin directory.

Be sure to:

  • Replace your_tns_alias with your TNS alias. For example, MYDB, PROD_DB, ORA_KRB

  • Replace your_hostname with your Oracle server hostname. For example, your-db-host.example.com, db.company.com

  • Replace your_port with your Oracle DB port. Usually. For example, 1521

  • Replace your_service_name with your service name. For example, MYDB, ORCL

loading
6

Configure JDBC properties

Create ojdbc.properties in your TNS admin directory.

Be sure to:

  • Replace your_tns_admin_dir with your absolute path to your TNS admin directory. For example, /home/user/tns-admin, /Users/name/tns-admin

  • Replace your_cc_name with your path for the Kerberos credential cache (must match sqlnet.ora). For example, /tmp/krb5cc_liquibase

  • Replace your_keytab_path with your path to your Kerberos keytab file (must match sqlnet.ora). For example, /etc/liquibase.keytab

loading
7

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 MYDB with your TNS alias from tnsnames.ora. For example, MYDB, PROD_DB

  • Replace liquibase-svc with your Kerberos principal (without realm). For example, liquibase-svc, lbsvc

loading
8

Set environment variables

Set the following environment variables before running Liquibase.

Be sure to:

  • Replace your_krb5_conf_path with the absolute path to your krb5.conf file. For example, /absolute/path/to/liquibase-krb/krb5.conf

  • Replace your_ojdbc_props_path with the absolute path to your ojdbc.properties file. For example, /absolute/path/to/liquibase-krb/ojdbc.properties

loading
9

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_realm with your Kerberos principal. For example, liquibase-svc@COMPANY.COM

  • Replace your_krb5_conf with the absolute path to your krb5.conf file (Headless only). For example, /absolute/path/to/liquibase-krb/krb5.conf

  • Replace your_keytab_path with the absolute path to your keytab file (Headless only). For example, /absolute/path/to/liquibase.keytab

  • Replace your_cc_name with the path for the credential cache. For example, /tmp/krb5cc_liquibase

kinit your_username@your_realm

loading

Verify the ticket was obtained.

loading

Set the credential cache environment variable so tools find it automatically.

loading
10

Run Liquibase (TCP)

Be sure to:

  • Replace your_krb5_conf_path with the absolute path to your krb5.conf file. For example, /absolute/path/to/liquibase-krb/krb5.conf

  • Replace your_ojdbc_props_path with the absolute path to your ojdbc.properties file. For example, /absolute/path/to/liquibase-krb/ojdbc.properties

  • Replace your_liquibase_krb_path with the absolute path to your working directory. For example, /absolute/path/to/liquibase-krb

loading

loading
11

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.com with your Oracle DB hostname

  • Replace 2484 with your Oracle TCPS port. Usually, 2484

loading
12

Create the wallet directory

Create the wallet directory inside your working directory.

mkdir -p wallet
13

Import the certificate into the wallet

Import the server certificate into the wallet. Use whichever approach is available on your system.

loading

loading
14

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.

loading
loading

Expected output:

Checking: wallet/cwallet.sso
Entries: 1
CN=db.company.com
  Subject: CN=db.company.com

If Entries: 0, the wallet is empty — re-run the previous step.

15

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.com with your Oracle DB hostname

  • Replace MYDB with your Oracle service name

  • Replace /absolute/path/to/wallet with the absolute path to your wallet directory

loading
16

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-krb with the absolute path to your working directory

  • Replace /absolute/path/to/liquibase.keytab with the absolute path to your keytab file

  • Replace /absolute/path/to/wallet with the absolute path to your wallet directory

  • Set oracle.net.ssl_server_dn_match=true if the server cert CN matches the hostname in your JDBC URL; set it to false if connecting via localhost, IP, or alias

loading
17

Run Liquibase with TCPS

The only changes from the TCP run are:

  • Use ojdbc_ssl.properties instead of ojdbc.properties

  • Add the three PKI JARs to the classpath

  • Use the MYDB_SSL TNS alias (TCPS, port 2484)

Be sure to:

  • Replace your_krb5_conf_path with the absolute path to your krb5.conf file

  • Replace your_liquibase_krb_path with the absolute path to your working directory

loading