Search code examples
sql-serverspringspring-bootjdbcsql-server-2012

How to ignore the warning: Please update server and client to use TLSv1.2 at minimum?


I am using Spring Boot 2.7.4 and SQL Server driver 11.2.1.jre8 on Java 8 to connect to SQL Server 2012 database which uses TLSv1 and the project runs on Tomcat 9.

JDBC driver dependency:

<dependency>
    <groupId>com.microsoft.sqlserver</groupId>
    <artifactId>mssql-jdbc</artifactId>
    <version>11.2.1.jre8</version>
</dependency>

My connection URL is as follows:

spring.datasource.url=jdbc:sqlserver://myhostname;databaseName=mydb;encrypt=false;

According to the Microsoft documentation setting encrypt=false will disable TLS encryption for all the data sent between the client and the server.

But I keep getting this warning:

[WARN] org.hibernate.engine.jdbc.spi.SqlExceptionHelper : TLSv1 was negotiated. Please update server and client to use TLSv1.2 at minimum.
[WARN] org.hibernate.engine.jdbc.spi.SqlExceptionHelper : SQL Warning Code: 0, SQLState: null

I cannot make changes on the database server right now to update it to use TLSv1.2, so is there any database connecting property I need to add or some Spring configuration to avoid this error ?

Update

I didn't get this error when I was using mssql-jdbc-8.2.1.jre8.jar, so is there any solution other than downgrading the JDBC driver ?


Solution

  • I can't tell for sure, but since you're using Spring, I assume that the warning you show is being emitted by the standard Spring logging system. If that's the case, and if that message has a level of WARN, then you can hide that warning by setting the logging level for the indicated package to ERROR in your application.properties file, like this:

    logging.level.org.hibernate.engine.jdbc.spi.SqlExceptionHelper: ERROR
    

    Of course, this is going to hide ALL warnings for that package. If that's not what you want, then I don't think there's anything you can do. I've often wanted something more granular myself...some way to eliminate particular warnings with a regular expression or something. I've never found such a feature in any of the standard logging systems.