Use TLS 1.2 in mssql jdbc - java

Starting which version of mssql-jdbc- jre8 is TLS 1.2 supported? Is a special configuration needed to use TLS 1.2? or it works out of the box)MSSQL server is set up to accept only TLS 1.2 connections)?

Starting which version of mssql-jdbc- jre8 is TLS 1.2 supported?
Java 8 supports TLS1.0 through TLS1.2, and TLS1.2 is the default; see Transport Level Security (TLS) and Java. The MSSQL JDBC drivers will use the JVM's SSL libraries.
Is a special configuration needed to use TLS 1.2?
No. Not on the client side.
or it works out of the box.
Yes.
MSSQL server is set up to accept only TLS 1.2 connections?
That would depend on how the database server itself is configured. According to "TLS 1.2 support for Microsoft SQL Server", SQL Server 2016 supports TLS 1.0 through 1.2, but you can configure it to disable versions that you don't want.

Related

Cannot establish a jdbc with MS SQL server in Netbeans

The message given is;
Cannot establish a connection to jdbc:sqlserver://HARSHS-PC\SQLEXPRESS;databaseName=mydb1 using com.microsoft.sqlserver.jdbc.SQLServerDriver 
(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]". ClientConnectionId:d7ef2454-53af-4f3c-995e-00c75b4d3f39)
How can I establish the connection?
What can be the possible solutions?
Your SQL server only offers TLS1.0 which is most likely disabled in your jre for security reasons.
I'd suggest that you upgrade your SQL Server to the most recent TLS version which is as of today TLS1.3 or at least to TLS1.2.
Another possibility (I would not recommend) would be to modify your java.security which is part of your java jre distribution. To reenable TLS1.0.

TLS version used in JDK 8

We initialise our SSL context with the following code and are running on Java 8.
SSLContext context = SSLContext.getInstance("SSL");
Since Java 8 uses TLSv1.2 by default? Does it mean the above code will start sending TLSv1.2 requests if my server supports it.
Want to understand if "SSL" protocol name is just an alias but java runtime starts sending the requests with default TLS version.
UPDATE
I ran my code against "https://www.google.co.in/" and found this in fiddler
A SSLv3-compatible ClientHello handshake was found. Fiddler extracted the parameters below.
Version: 3.3 (TLS/1.2
And also if i change my protocol to TLSv1 which only supports 1.0. Then Fiddler tells me
A SSLv3-compatible ClientHello handshake was found. Fiddler extracted the parameters below.
Version: 3.1 (TLS/1.0)
So, I guess the above code with "SSL" protocol name should work well with TLS 1.2 servers.
Yes. In Java 7, server side default TLS version was 1.2. In Java 8 both server and client have default TLS version 1.2.
As TLS version is backward compatible on both side unless server is configured strictly to specific version should not be an issue.

Set TLS version 1.2 to MS Sql JDBC Client

I am writing a spring boot application which uses MS Sql jdbc driver to connect to an SQL Server located in a remote machine.
According to microsoft's documentation i have enabled the setEncryption option which enabled the secured connection.
Version of spring boot is 1.5.8.
Ms Sql jdbc client version
<mssql-jdbc.version>6.1.0.jre7</mssql-jdbc.version>
How do i set the TLS versions that should be used to do the handshake with the server ?
According to MS Doc, the driver should use the ssl settings that are set in the JSSE.
So, i added the following settings in the application.yml
server:
ssl:
enabled: true
protocol: TLS
enabled-protocols: TLSv1.2
I suppose this configuration should be picked up by spring boot and ultimately by the JSSE.
But this doesn't seem to work.
Wireshark trace shows that the tls version used is still 1.0
I googled a lot but didn't find any direct API or config file to set the TLS version configuration to the JSSE of the application.
I know that SSLContext with SSLContextFactory etc can be used to configure the TLS versions and for http/https calls.
But how do i set to JSSE so that MS SQL Jdbc driver uses that configuration to create a connection.

How to configure what TLS version is used for JMX over SSL?

I need to configure TLSv1.2 for JMX communication.
Unfortunately I can not find the appropriate configuration here:
https://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html
How to configure what TLS version is used for JMX over SSL?
PCI DSS 3.1 does not allow usage of TLS 1.0.
You have obviously not read the documentation you have linked. It says:
com.sun.management.jmxremote.ssl.enabled.protocols: Default SSL/TLS protocol version.
com.sun.management.jmxremote.ssl.enabled.cipher.suites: Default SSL/TLS cipher suites.
This should solve your problem. After you have configured that, scan your JXM port with sslscan with a recent version (1.0.2+) of OpenSSL.

Client in java 6 for doint http post on tls

I have a consumed a payment gateway to which I was doing http post. Now payment gateway has been changed to tlsv1.2. Can I do http POST from java code, in tls v1.2 ??
I am current on java 1.6, server is tomcat.
Sources say I have to move to 1.7 .. Is it true ??
And can anybody guide me to how to do httpPost via tls v1.2
any refrence regarding same is welcome
Sources say I have to move to 1.7 .. Is it true ??
Yes, you have to move to 1.7 as JDK6 only supports TLSv1.
cf. https://blogs.oracle.com/java-platform-group/entry/diagnosing_tls_ssl_and_https
Note that TLSv1.1 and TLS1.2 are by default not enabled for client connections in 1.7 (they are in 1.8):
Although SunJSSE in the Java SE 7 release supports TLS 1.1 and TLS
1.2, neither version is enabled by default for client connections. Some servers do not implement forward compatibility correctly and
refuse to talk to TLS 1.1 or TLS 1.2 clients. For interoperability,
SunJSSE does not enable TLS 1.1 or TLS 1.2 by default for client
connections.

Categories

Resources