'MsSQL driver which could not establish a secure connection by using Secure Sockets Layer (SSL)?
I use standard driver com.microsoft.sqlserver.jdbc.SQLServerDriver to connect to a MSSQL server. I run my program in Eclipse and encounter error:
Failed to obtain JDBC Connection; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException:
The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption.
Error: "The server selected protocol version TLS10 is not accepted by client preferences [TLS13, TLS12]"
My environment is openjdk version "11.0.11" 2021-04-20 LTS and the project use same JRE system library in Eclipse. The weird thing is, I package my project to JAR and it runs well in another machine, which is openjdk version "11.0.9.1" 2020-11-04 LTS.
A few months ago, I was able to run my program in the development environment, but now I fail. I may have made some changes to the development environment during this period, so I don't know if it has anything to do with the JDK version.
Any hint is welcome and thank you in advance.
Solution 1:[1]
Thanks for SchmitzIT! The thread is actually guide me to a workable solution which I would like to re-post here for a record!
https://aws.amazon.com/blogs/opensource/tls-1-0-1-1-changes-in-openjdk-and-amazon-corretto/
Above article have some valuable information which works for me:
- JDK8 8u292 and newer, JDK11 11.0.11 and newer, JDK16 is disabling TLS 1.0 and 1.1
- Modify (remove TLSv1 and/or TLSv1.1) jdk.tls.disabledAlgorithms in java.security configuration file located in the jre/lib/security folder for OpenJDK 8 or conf/security for OpenJDK 11 and higher will enable legacy TLS!
PS. But add a file enableLegacyTLS.security to override setting in java.security doesn't work for me (OpenJDK 11). Don't know why.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |