dbd67a4 Dec 5, 2017
2 contributors

Users who have contributed to this file

@rusher @thegounet
133 lines (99 sloc) 6.04 KB

GSSAPI Authentication

MariaDB GSSAPI support GSSAPI since the 10.1 version (Server configuration can be found on ).

The following subsections show how to implement GSSAPI Authentication with the java connector.

Support history:

  • version 1.4.0 : java connector support
  • version 1.5.0 : added native windows implementation.

General configuration

Database configuration must have been set. To use GSSAPI authentication, a user must be set to use GSSAPI : ``` CREATE USER one IDENTIFIED VIA gssapi AS 'userOne@EXAMPLE.COM'; ```

When connecting to database using for example for example using jdbc url : DriverManager.getConnection(""); These user is send to database and GSSAPI authentication will be use. The principal (userOne@EXAMPLE.COM in example) must be the one defined on the user definition.

Database server will wait for a ticket associated for the principal defined in user ('userOne@EXAMPLE'). That mean on client, user must have obtained a TGT beforehand.

As part of the security context establishment, the driver will initiate a context that will be authenticated by database. Database also be authenticated back to the driver ("mutual authentication").

GSSAPI configuration

Java system properties

Realm information are generally defined by DNS, but this can be forced using system properties. "" defined the Key Distribution Center (KDC), realm by "". Example :

        System.setProperty("", "");
        System.setProperty("", "EXAMPLE.COM");

Logging can be set using additional properties:

        System.setProperty("", "true");
        System.setProperty("", "true");

Java JCE

Depending on the kerberos ticket encryption, you may have to install the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy File. (CentOS/Red Hat Enterprise Linux 5.6 or later, Ubuntu are using AES-256 encryption by default for tickets).

On unix, you can execute the "klist -e" command to view the encryption type in use: If AES is being used, output like the following is displayed after you type the klist command (note that AES-256 is included in the output):

    Ticket cache: FILE:/tmp/krb5cc_0
    Default principal: userOne@EXAMPLE
    Valid starting     Expires            Service principal
    03/30/15 13:25:04  03/31/15 13:25:04  krbtgt/EXAMPLE@EXAMPLE
    Etype (skey, tkt): AES-256 CTS mode with 96-bit SHA-1 HMAC, AES-256 CTS mode with 96-bit SHA-1 HMAC


On windows GSSAPI implementation is SSPI. The java 8 native implementation as many limitations (see java ticket).

Driver contain 2 Different implementations:

  • a java standard implementation will use JAAS to allow java to access TGT.
  • a windows native implementation based on Waffle

Standard java SSPI implementation


The driver will use the native ticket cache to get the TGT available in it using JAAS. If the System property "" is empty, driver will use the following configuration :

    Krb5ConnectorContext { required 

This permit to use current user TGT cache

limitation on windows

Main limitation are :

  • To permit java to retrieve TGT (Ticket-Granting-Ticket), windows host need to have a registry entry set.
  Value Name: AllowTGTSessionKey
  Value Type: REG_DWORD
  Value: 1
  • Kinit command must have been executed previously to connection.

Windows native java implementation

Implementation is based on Waffle that support windows SSPI based on JNA.

if waffle-jna (and dependencies) is in classpath, native implementation will automatically be used. (This permit to avoid any specific problem with admin right, registry, kinit ...)

Dependencies :

Possible errors

  • "GSSException: Failure unspecified at GSS-API level (Mechanism level: No Kerberos credentials available)"

There is no active credential. Check with klist that there is an existing credential. If not create it with the "kinit" command

  • "java.sql.SQLInvalidAuthorizationSpecException: Could not connect: GSSAPI name mismatch, requested 'userOne@EXAMPLE.COM', actual name 'userTwo@EXEMPLE.COM'"

There is an existing credential, but doesn't correspond to the connection user. example : if user is created with a command like ```script CREATE USER userOne@'%' IDENTIFIED WITH gssapi AS 'userTwo@EXAMPLE.COM'; ``` klist must show the same principal (userTwo@EXAMPLE.COM in this example)

  • "GSSException: No valid credentials provided (Mechanism level: Clock skew too great (37))". The Kerberos protocol requires the time of the client

and server to match: if the system clocks of the client does not match that of the KDC server, authentication will fail with this kind of error. The simplest way to synchronize the system clocks is to use a Network Time Protocol (NTP) server.