I am trying to connect my web application to SQL server 2012 with SSL encryption enabled using sqljdbc4 but i get the below error :

com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "SQL Server did not return a response. The connection has been closed. ClientConnectionId:aae3c3a9-9b39-4141-aeda-577e06a28dfd". at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1667) at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1668) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1323) at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827) at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012) at java.sql.DriverManager.getConnection(DriverManager.java:571) at java.sql.DriverManager.getConnection(DriverManager.java:215) ... 41 more Caused by: java.io.IOException: SQL Server did not return a response. The connection has been closed. ClientConnectionId:aae3c3a9-9b39-4141-aeda-577e06a28dfd at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.ensureSSLPayload(IOBuffer.java:651) at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.readInternal(IOBuffer.java:708) at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.read(IOBuffer.java:700) at com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.readInternal(IOBuffer.java:895) at com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.read(IOBuffer.java:883) at sun.security.ssl.InputRecord.readFully(InputRecord.java:442) at sun.security.ssl.InputRecord.read(InputRecord.java:480) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:927) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323) at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1618)

please note that the server certificate key size exceeds 4k. when I try to connect to the SQL server using SQL management studio I get the below error:

A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - An existing connection was forcibly closed by the remote host.) (Microsoft SQL Server, Error: 10054)

but when I use certificate with key size less than 4k I was able to connect without any errors. reducing certificate size is not acceptable solution so what can I do to be able to connect to SQL server 2012 using sqljdbc 4 with SSL enabled and using certificate with key size larger than 4k.

  • It sounds like the version of SQL Management Studio you are using does not support certiicates with a key size you are rquired to use. I suggest using a different tool to verify that is the case.
    – Ramhound
    Oct 20, 2015 at 14:10
  • what might be an alternative tool other than sql Management studio, that might support my certificate key size ?, anyhow even if SQL management studio doesn't support large certificate size, why when I connect from Java I get the same error ?
    – QuakeCore
    Oct 20, 2015 at 14:13
  • If I must be honest I suspect it also is a incompatibility with either Java or SQLServer itself. Having a 4k key certificate was nearly unheard of in 2011 when both SQLServer 2012 and Management Studio 2012 was released. hence the suggestion of using a different tool.
    – Ramhound
    Oct 20, 2015 at 14:38


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.