Skip to content

Instantly share code, notes, and snippets.

@micalbrecht
Last active February 9, 2023 18:00
Show Gist options
  • Save micalbrecht/7c27eb80418fc7070a31852e86074742 to your computer and use it in GitHub Desktop.
Save micalbrecht/7c27eb80418fc7070a31852e86074742 to your computer and use it in GitHub Desktop.

Upgrade to Spring Boot 2.7.7 with com.microsoft.sqlserver -> mssql-jdbc

Problem

spring.datasource.url=jdbc:sqlserver://url-to-sql-server;databaseName=db-name;

'PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Solution

Trust the Microsoft SQL Server Certificate with "trustServerCertificate=true;".

spring.datasource.url=jdbc:sqlserver://url-to-sql-server;databaseName=db-name;trustServerCertificate=true;

Sources

Microsoft Driver Infos: https://learn.microsoft.com/en-us/sql/connect/jdbc/connecting-with-ssl-encryption?view=sql-server-ver16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment