Loading

Kerberos Authentication to Microsoft SQL Server database from mule-4 app hosted in CloudHub or RTF

Дата публикации: Jun 24, 2026
Задача

GOAL

The goal of this knowledge article is to explain how to connect to Kerberos-enabled Microsoft SQL Server from Mule 4 app which is to be deployed in CloudHub or RTF or a Linux Based on-premise server.

PREREQUISITE

Before conducting the procedure below, the Microsoft SQL Server has to be enabled with Kerberos authentication and you should have the kdc, realm, and keytab file derived from the Kerberos password. For instructions, refer to this Microsoft article.
Also, make sure that you use the latest version of the Database connector by referring to this Database connector Release Notes.
Действия

You can find a sample mule 4 application attached with this article to connect Kerberos enabled Microsoft SQL Serve using Database connector. Below are the different steps to be followed to configure the app.

  1. Create database connector configuration in mule application using the latest version of the Microsoft JDBC Driver (6.2 and above) which supports Kerberos authentication. Also, make sure to add the driver in Shared Libraries as well. The below version is just an example so consider using a version that is compatible with your Microsoft SQL Server.
            <dependency>
                <groupId>com.microsoft.sqlserver</groupId>
                <artifactId>mssql-jdbc</artifactId>
                <version>6.4.0.jre8</version>
            </dependency>
          <sharedLibrary>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
          </sharedLibrary>

 

  1. Create the Database connector configuration with the URL specified in the below format.
        <db:config name="Database_Config" doc:name="Database Config" doc:id="63c99ba2-67df-4d79-aa89-ee796bf9769a">
            <db:generic-connection
                url="jdbc:sqlserver://<hostname>;databaseName=<DB Name>;integratedSecurity=true;authenticationScheme=JavaKerberos;"
                driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
        </db:config>
    

 

  1. Create SQLJDBCDriver.conf file under the "src/main/resources" folder with the below content for your CloudHub or RTF or Linux-based environments. 

    NOTE: Both keytab and conf files will require the absolute path to be used during the deployment. Make sure to use the absolute paths for the files as below for points 3 and 4.

    SQLJDBCDriver { 
    	com.sun.security.auth.module.Krb5LoginModule required
    	useKeyTab=true
    	keyTab="/opt/mule/mule-CURRENT/apps/<application name>/mulesoftcommon.keytab"
    	useTicketCache=false
    	doNotPrompt=true
    	principal="mulesoft_common_dev@MULESOFT.COM";
    };
    While using the Anypoint studio on your Windows machine, make sure that you use the below format in "keyTab". The path must contain "\\".
SQLJDBCDriver { 
	com.sun.security.auth.module.Krb5LoginModule required
	useKeyTab=true
	keyTab="C:\\<folder-path-to-keytab-file>\\mulesoftcommon.keytab"
	useTicketCache=false
	doNotPrompt=true
	principal="mulesoft_common_dev@MULESOFT.COM";
};

where,

          keyTab points to the absolute path of the keytab file which is generated from Kerberos credentials
          principal in the format user@domain
 

  1. Deploy the application with the below JVM arguments.
    NOTE : Please note that 'TestConnection' Button will not work in case on Kerberos authentication, just like for oAuth2.0,  One have to deploy the application to get the connectivity tested, that is expected and by design.
    1. For CloudHub, pass the JVM arguments under System properties. Refer to this documentation https://docs.mulesoft.com/runtime-manager/deploying-to-cloudhub#properties-tab-settings.
    2. For Runtime Fabric (RTF), set the JVM arguments in the JVM tab. Refer to this article https://help.salesforce.com/s/articleView?id=How-to-Get-List-of-JVM-Arguments-Passed-to-an-RTF-App-Deployment&type=1&language=en_US
    3. For Anypoint Studio, pass the JVM arguments in "Run configurations > Arguments tab > VM Arguments". Refer to this article https://help.salesforce.com/s/articleView?id=How-can-I-set-Mule-and-Java-system-properties-at-startup&type=1&language=en_US
java.security.auth.login.config=/opt/mule/apps/<application name>/SQLJDBCDriver.conf
java.security.krb5.kdc=KDC01.mulesoft.com
java.security.krb5.realm=MULESOFT.COM
If you are using Anypoint studio on a windows machine then change the conf path as below.
java.security.auth.login.config=C:\<path-to-your-studio-project>\src\main\resources\config\SQLJDBCDriver-local.conf 
where,
       java.security.krb5.kdc and java.security.krb5.realm are the kdc and realm for your Kerberos setup.
Note: The value of java.security.krb5.realm should be in upper case letters.
 

To summarize, below is the structure to use for configuring keytab and conf file paths in different environments.
  • If the application is deployed in CloudHub, the absolute path of the keytab and conf files will look like the below,
/opt/mule/mule-CURRENT/apps/<application name>/mulesoftcommon.keytab
/opt/mule/mule-CURRENT/apps/<application name>/SQLJDBCDriver.conf
  • If the application is deployed in RTF, the absolute path of the keytab and conf files will look like the below,
/opt/mule/apps/<application name>/mulesoftcommon.keytab
/opt/mule/apps/<application name>/SQLJDBCDriver.conf
  • If the application is executed on your Anypoint studio on a windows machine, the absolute path of the keytab and conf files will look like the below,
C:\\<folder-path-to-keytab-file>\\mulesoftcommon.keytab
C:\<path-to-your-studio-project>\src\main\resources\config\SQLJDBCDriver-local.conf


 

Дополнительные ресурсы
kerberos-db-example

Disclaimer: 
  • This example project is provided as a reference for your own usage and it's not part of the official Mule product so its use will be considered as a custom implementation made by the customer.
  • This article involves products and technologies which do not form part of the MuleSoft product set. Technical assistance for such products is limited to this article.
Номер статьи базы знаний

001116985

 
Загрузка
Salesforce Help | Article