
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 06-24-2023 03:38 AM
I faced this issue with one of my customers, and I had to spend a substantial amount of time reading ServiceNow and Microsoft documentation, so I thought I'd summarize the solution which finally helped to solve the task.
1. Update JDBC driver on MID server and provide MSAL4J library:
- Download the latest JDBC driver for SQL Server from the Microsoft website, unzip it. We will need only the JAR file with jre11 in the name.
- Download MSAL4J library from the Maven repository (the official repository for Microsoft libraries). This is also a JAR file.
- Login to ServiceNow with an account having admin privileges, go to MID Server > JAR files, add both JAR files by creating two new records in this table, and then by attaching one JAR file to each record.
- Deactivate any other records with JAR files in case there are any of them in this table.
- As suggested by this knowledge article, add these two lines to agent/conf/wrapper-override.conf file on the MID server:
wrapper.java.classpath.1=extlib/*.jar
wrapper.java.classpath.2=lib/*.jar
- Restart the MID server. Make sure it restarts successfully.
2. Make sure that agent/extlib directory contains both two JAR files which we’ve uploaded to ServiceNow, and only them.
- In case you need some other JAR files for other purposes, you can keep them enabled, but some of them might lead to errors when restarting MID server. To isolate the JAR file leading to errors, deactivate all JAR files except JDBC driver and MSAL4J library, and then start activating them one by one in ServiceNow, restart MID server each time and make sure there’s no error.
- Enable proper domain name resolution for the FQDN of the SQL server. In case you are using private endpoint, the FQDN should point to an internal IP address. Either change DNS configuration on the MID server, or add a line to /etc/hosts file:
<IP address of private endpoint> <FQDN of private endpoint>
3. Make sure there’s network connectivity between MID server and the SQL server via private endpoint. In order to do it, after enabling proper domain name resolution, run this command:
openssl s_client -connect <FQDN of private endpoint>:<port, usually it is 1433 for SQL Server>
You should see CONNECT in the first line of the output, and then the SSL certificate of the SQL server.
4. Configure a data source in ServiceNow:
- Add Connection URL field to the form of the data source.
- When configuring data source, use:
- Type = “JDBC”
- Format = “SQLServer”
- Connection URL = “jdbc:sqlserver://<FQDN of private endpoint>:<port>;databaseName=<name of the database>;hostNameInCertificate=<see below>;authentication=ActiveDirectoryServicePrincipal”
- Username = the application (client) ID of the service principal
- Password = the service principal secret
- Query = “Specific SQL” (we are using this because the names of the views in SQL Server might be too long for respective field in ServiceNow, and because you might want to apply some filter when fetching data from SQL Server)
- SQL statement = “SELECT * FROM <table or view name, make sure you align with DB experts to use proper prefix before the name of the view or table>;”
- When saving data source record, check that connection URL and SQL statement which you have provided are not overwritten by ServiceNow with something else. If it is overwritten, change them again and save the record again.
5. Test the connection by loading 20 records:
- There might be an error saying something about wrong hostname in certificate. The text of the error will mention the name in the actual certificate from the SQL server. You can remediate this error by adjusting the hostNameInCertificate parameter in your JDBC connection URL.
- 6,943 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hello Anton,
Thanks for the article. This was helpful for me to integrate ServiceNow with DataLake using a domain account & its password with the below connection string. But, because of the new JAR files, the existing SCCM connection stopped working with an error mentioned below as well:
jdbc:sqlserver://<FQDN of private endpoint>:<port>;database=<name of the database>;encrypt=true;trustServerCertificate=false;hostNameInCertificate=<wild card URL>;loginTimeout=30;authentication=ActiveDirectoryPassword
MID Server reported error: SQLState: null
java.sql.SQLException: com.microsoft.sqlserver.jdbc.SQLServerException: "encrypt" property is set to "true" and "trustServerCertificate" property is set to "false" but the driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption: Error: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target.
Have you come across this situation and any fix?
Regards,
Sharad
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
We are getting below error:
Any idea what caused this issue ?
I have followed all the steps as mentioned above.
Thanks,
Sanyam Bhagat
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi
Have you found what is causing the error?
I am also receiving the same error after following the steps above:
MID Server reported error: java.lang.NoSuchMethodError: 'com.microsoft.aad.msal4j.AbstractApplicationBase$Builder com.microsoft.aad.msal4j.ConfidentialClientApplication$Builder.executorService(java.util.concurrent.ExecutorService)'
Regards,
Dominik
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi,
We used version msal4j-1.15.1.jar and it worked fine.
Regards,
Dominik
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Does this apply to a MID Server running on a Linux Server
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
This worked with MID Server running on Windows
Thank you @Anton Lykov