Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "Unexpected rethrowing". #879

Closed
martinm1000 opened this issue Nov 13, 2018 · 39 comments
Assignees
Projects

Comments

@martinm1000
Copy link

Driver version

mssql-jdbc-7.1.2.jre11
mssql-jdbc-7.0.0.jre10 ( i think I got the problem with this one too)

Problem / Question

I've been refactoring my database connection code, and I probably have a new non-oblivious problem since but I need some pointers on what is going on in the mssql driver.

I seem to have random problems creating SQL connections that otherwise would work ok. I get the following stacktraces while connecting to a NON-ENCRYPTED sql server 2017 database.

Can someone explain the TDS Prelogin negociations vs SSL vs any other encryption scheme that might explain why I get this exception sometimes ? Or is this wrong exception message ? Is there some SSL going on to login even if we don't have encrption setup on the sql server side ?

com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "Unexpected rethrowing".
        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2826)
        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1829)
        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2391)
        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2042)
        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1889)
        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1120)
        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:700)
        at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
Caused by: javax.net.ssl.SSLProtocolException: Unexpected rethrowing
        at java.base/sun.security.ssl.Alert.createSSLException(Unknown Source)
        at java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)
        at java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)
        at java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)
        at java.base/sun.security.ssl.SSLTransport.decode(Unknown Source)
        at java.base/sun.security.ssl.SSLSocketImpl.decode(Unknown Source)
        at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(Unknown Source)
        at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1756)
        ... 41 more
Caused by: java.io.IOException: SQL Server returned an incomplete response. The connection has been closed. ClientConnectionId:b9ef7c65-28e5-4858-9cc1-642eaa2725d1
        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.ensureSSLPayload(IOBuffer.java:786)
        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.readInternal(IOBuffer.java:836)
        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.read(IOBuffer.java:829)
        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.readInternal(IOBuffer.java:999)
        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.read(IOBuffer.java:989)
        at java.base/sun.security.ssl.SSLSocketInputRecord.read(Unknown Source)
        at java.base/sun.security.ssl.SSLSocketInputRecord.decode(Unknown Source)
        ... 46 more
@peterbae
Copy link
Contributor

Hi @martinm1000, could you share your connection string that you're using to produce this error?

@martinm1000
Copy link
Author

martinm1000 commented Nov 13, 2018

@peterbae Its the most simple one:

jdbc:sqlserver://WKS-DEV-23;encrypt=false;user=user;password=xxxxxx;applicationName=xxx;databaseName=XXXXX

by rapidly reloading data in my app I just got the exception again (even with encrypt=false which I just added).

@martinm1000
Copy link
Author

I can confirm I also can get this exception using mssql-jdbc-7.0.0.jre10.

@martinm1000
Copy link
Author

I think I'll try to write a small test class that could reproduce it.

I'm having a hard time reproducing it, but right now by best way to do it is by running my app from a java 11 runtime image with everything on the module path. Not sure if this is really a factor or not. I need to quickly reload stuff in my app to trigger new sql connection in a quick succession and then I might get the exception.

@martinm1000
Copy link
Author

ssllog.txt

I'm attaching a text log of reproducing the problem with the jvm option -Djavax.net.debug=ssl:handshake if this can be helpfull.

@martinm1000
Copy link
Author

I believe this kind of error should have a internal retry as some other type of internal ssl errors are retried in the driver (SQLServerException.DRIVER_ERROR_INTERMITTENT_TLS_FAILED), but it doesn't looks like this one get another chance on the first fail, unless I'm mistaken. (SQLServerException.DRIVER_ERROR_SSL_FAILED)

@ulvii ulvii self-assigned this Nov 14, 2018
@ulvii
Copy link
Contributor

ulvii commented Nov 14, 2018

Hi @martinm1000 ,
Please post the exact java version (output of java -version). Also what Operating System is the application running on?

@martinm1000
Copy link
Author

Hi @ulvii

Windows 10

openjdk 11.0.1 2018-10-16
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.1+13)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.1+13, mixed mode)

I'm about to post a "working" test case that sometimes reproduce the problem (a simple loop). I am currently trying to find out why I sometimes can't get it to crash... and well... its a bizarre one.

Right now I can only have it trigger when I running on a JLINKED runtime and not from the complete JDK runtime. Anyways, I'm running some more tests before posting it.

But that would match what I see since yesterday and why I havent seen that problem before my tests under Java 11.

@ulvii
Copy link
Contributor

ulvii commented Nov 14, 2018

Could you use connection property sslProtocol=TLSv1 to force the driver to use TLS 1.0 and let me know if you are still seeing failures? Your connection string would become jdbc:sqlserver://WKS-DEV-23;encrypt=false;user=user;password=xxxxxx;applicationName=xxx;databaseName=XXXXX;sslProtocol=TLSv1;

@martinm1000
Copy link
Author

So far so good with TLSv1. At least we have that ;-)

@ulvii
Copy link
Contributor

ulvii commented Nov 14, 2018

Great, now we confirmed that you are seeing the failures because of intermittent TLS1.2 issues.

Please take a look at this article, which explains the cause of the issue (changes to Windows ciphers) and also possible resolution/workarounds.

I would also like to explain why the driver is unable to retry when there is a logic implemented for this. Intermittent TLS1.2 issue is "guessed" by the driver based on the error message from the server. See this line. For some reason, your JDK version wraps the actual and expected exception message SQL Server returned an incomplete response. The connection has been closed. into Unexpected rethrowing. Below is the stack trace of my application with Oracle JDK 11.0.1+13.

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 returned an incomplete response. The connection has been closed.". ClientConnectionId:f155980e-207c-48c5-a2e4-804bdeb655b9
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2825)
	at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1812)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2391)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2042)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1889)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1120)
	at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:700)
	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)
	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:228)
	at Issue849.main(Issue849.java:14)
Caused by: javax.net.ssl.SSLProtocolException: SQL Server returned an incomplete response. The connection has been closed.
	at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:126)
	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:321)
	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:264)
	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:259)
	at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:137)
	at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1152)
	at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1063)
	at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:402)
	at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1741)
	... 8 more
Caused by: java.io.IOException: SQL Server returned an incomplete response. The connection has been closed.
	at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.ensureSSLPayload(IOBuffer.java:772)
	at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.readInternal(IOBuffer.java:821)
	at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.read(IOBuffer.java:814)
	at com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.readInternal(IOBuffer.java:984)
	at com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.read(IOBuffer.java:974)
	at java.base/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:448)
	at java.base/sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:165)
	at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:108)
	... 12 more

Notice how Caused by: javax.net.ssl.SSLProtocolException: SQL Server returned an incomplete response. The connection has been closed. is different from yours, hence the driver throws the exception without retrying.

Please let me know if you have any other questions.

@martinm1000
Copy link
Author

Thanks, I'll have a look at this. But I'm not sure it answer it all... Right now, I can reproduce the problem using a jlinked java runtime... which is what we're supposed to do now...

I'll do tests with Oracle's JDK tomorrow.

Here's my test case

SSLFail.zip

Directory Layout

mssql-jdbc-7.1.2.jre11-preview.jar
test
TriggerSSLFailure.java

Instructions

"c:\Program Files\Java\jdk-11.0.1+13\bin"\javac --class-path mssql-jdbc-7.1.2.jre11-preview.jar TriggerSSLFailure.java

The test file contains arguments for the program (sql url, etc)

When executing with the full JDK I never (not yet anyway) got the exception :

"c:\Program Files\Java\jdk-11.0.1+13\bin\java.exe" @test

I only might get the exception when running from a jlinked minimal java runtime. (that's what bothering me for now).

Look at used modules

"c:\Program Files\Java\jdk-11.0.1+13\bin\jdeps.exe" -s mssql-jdbc-7.1.2.jre11-preview.jar TriggerSSLFailure.class

Generate a runtime for our app

"c:\Program Files\Java\jdk-11.0.1+13\bin\jlink.exe" --no-header-files --no-man-pages --compress=2 --strip-debug --add-modules java.logging,java.naming,java.security.jgss,java.sql,java.transaction.xa,java.xml --output runtime

run the test program with this runtime. I sometimes get the exception...

runtime\bin\java.exe @test

@martinm1000
Copy link
Author

martinm1000 commented Nov 14, 2018

Question: how did you get the stacktraces without it just retrying and silencing them since you do have the expected exception message (and not the Unexpected rethrowing) ?

edit: can I see your Issue849.java ?

@ulvii
Copy link
Contributor

ulvii commented Nov 14, 2018

When executing with the full JDK I never (not yet anyway) got the exception
I suggest to get the JDBC logs and compare them between full JDK and minimal JRE. I suspect the intermittent TLS1.2 issue happens in both cases, but with full JDK the driver actually retries. You would need to add the following lines to your application to get the logs on console:

ConsoleHandler cs = new ConsoleHandler();
cs.setFormatter(new SimpleFormatter());
cs.setLevel(Level.FINEST);
Logger.getLogger("").addHandler(cs);
Logger logger = Logger.getLogger("com.microsoft.sqlserver.jdbc");
logger.setLevel(Level.FINEST);

If retry actually happens, you will see a line: Connection failed during SSL handshake. Retrying due to an intermittent TLS 1.2 failure issue.

Another possibility is that DHE suites are disabled for the JDK as mentioned in this article.

How did you get the stacktraces without it just retrying and silencing them since you do have the expected exception message (and not the Unexpected rethrowing) ?
I didn't reproduce the exact intermittent failure, instead I made ensureSSLPayload() to always fail with Caused by: java.io.IOException: SQL Server returned an incomplete response. The connection has been closed. Driver retries INTERMITTENT_TLS_MAX_RETRY = 5 times and gives up.

@martinm1000
Copy link
Author

Ok, I'll try that Thursday.

I've already looked at that article earlier today. Its really bizarre because I don't get why java would not use fixed key sizes, which this article state might be the source of the intermittent failure (when less than 1024).

Still I'll do more tests, we need to find the source of the "Unexpected rethrowing" because since this bypass the driver retry logic, this problem might become bigger in the future...

@martinm1000
Copy link
Author

I could not get the retry logged message when running on the full jdks, I don't get why, its like it never needed to retry ?

I tested Oracle commercial jdk and Oracle open jdk build. Its all the same as for AdoptOpenJDK.
Running on full JDK all look OK. Running on a JLINKED image from each JDK, they all get the same problem (Unexpected rethrowing) that bypass this driver retry logic...

I'm going to have a look at finding more about that "Unexpected rethrowing".

But it does look like the current retry logic won't work on jlinked jdk 11 runtimes.

@martinm1000
Copy link
Author

Well I have no idea. I suppose I'll go with SSLv1 and hope its support never goes away...
Someone else will have to look/test this, I don't see what else I can do.

java.base/sun.security.ssl TransportContext:293

// Note: close_notify is not delivered via fatal() methods.
    void fatal(Alert alert, String diagnostic,
            boolean recvFatalAlert, Throwable cause) throws SSLException {
        // If we've already shutdown because of an error, there is nothing we
        // can do except rethrow the exception.
        //
        // Most exceptions seen here will be SSLExceptions. We may find the
        // occasional Exception which hasn't been converted to a SSLException,
        // so we'll do it here.
        if (closeReason != null) {
            if (cause == null) {
                if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
                    SSLLogger.warning(
                            "Closed transport, general or untracked problem");
                }
                throw alert.createSSLException(
                        "Closed transport, general or untracked problem");
            }

            if (cause instanceof SSLException) {
                throw (SSLException)cause;
            } else {    // unlikely, but just in case.
                if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
                    SSLLogger.warning(
                            "Closed transport, unexpected rethrowing", cause);
                }
                throw alert.createSSLException("Unexpected rethrowing", cause);
            }
        }
Caused by: javax.net.ssl.SSLProtocolException: Unexpected rethrowing
        at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:126)
        at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:293)
        at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:264)
        at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:259)
        at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:137)
        at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1152)
        at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1063)
        at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:402)
        at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1756)

@martinm1000
Copy link
Author

martinm1000 commented Nov 15, 2018

You can generate a debugable image using the following command. Running on this java image will allow you to get the real TLS 1.2 issue sometimes, which I always get using a <2000 connections. I even once got the issue at the first connection !

jlink.exe --compress=2 --add-modules java.base,java.logging,java.naming,java.security.jgss,java.sql,java.transaction.xa,java.xml,java.instrument,jdk.jdwp.agent --output runtime

I can see that in debug that the Exception (Unexpected) has the IOException (incomplete response) as a cause. Persharps adding a new if branch for this case here would be a safe way to support what I see (but don't fully understand why this happen).

unexpected

As for running on the full JDK, I can't get that same breakpoint to trigger, so its like we don't even have the TLS 1.2 issue...

@martinm1000
Copy link
Author

martinm1000 commented Nov 15, 2018

Possible explanation I'm currently looking at:

  • Running on the full JDK, TLSv1.2 advertise a LOT more cipher suites than a minimal jlinked runtime.
  • Its possible the old retry code stopped working a long time ago, but cipher changes in the JDK mean some other cipher got selected and was not subject to the intermittent bug.
  • Java 11? runtimes generated from jlink don't export all the same cipher suites and the one used is subject to the intermittent bug.

What do you think ?

@ulvii
Copy link
Contributor

ulvii commented Nov 15, 2018

Hi @martinm1000 ,

I am pretty sure the retry logic still works, as long as the actual error message does not get wrapped into something else in the middle.

I also think it is fair to also check for the error message of the e.getCause(), for which I will create a PR soon and ask the team to review it.

@martinm1000
Copy link
Author

@ulvii

I am pretty sure the retry logic still works, as long as the actual error message does not get wrapped into something else in the middle.

I'm not so sure about this. But difficult to prove as the problem is not easy to reproduce (well if you forgot my case here).

Ok, so I found out that if someone generate a runtime image with the additional modules below, the jlinked image will advertise for TLS the same algorithms that the full runtime do. And I guess we will have an algo used that won't be subject to the intermittent issue.

So this might be a solution (we're shoving the real problem under the carpet but....)

jdk.crypto.ec,jdk.crypto.cryptoki

@martinm1000
Copy link
Author

martinm1000 commented Nov 15, 2018

As for the code that wrap the exception, I think the current sun.security.ssl.TransportContext implementation that does this changed in the last couple of JDK releases.

If I check for Java 8 jsse.jar for sun.security.ssl.TransportContext it doesn't exists.

So it might really be the case that the non-wrapped exception stopped working a while ago, but changes in ciphers available for TLS masked this. I think it should be assumed that this is the current way the exception would happen.

Thank you for the help !

@ulvii
Copy link
Contributor

ulvii commented Nov 15, 2018

@martinm1000 , if you take a look at the stack trace I have posted above, you can see that TransportContext.fatal() does not wrap the actual error message into Unexpected rethrowing, at least with Oracle JDK 11.0.1+13. And I also verified that, if exception message is not wrapped into some other message, the driver retries properly.

Caused by: javax.net.ssl.SSLProtocolException: SQL Server returned an incomplete response. The connection has been closed.
	at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:126)
	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:321)
	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:264)
	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:259)
	at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:137)
	at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1152)
	at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1063)
	at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:402)
	at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1741)

If you completely want to be sure, you can put a breakpoint in ensureSSLPayload() (this is where the original SQLServerException is caught and re-thrown as IOException) and trigger the TLS1.2 issue to verify the exception message. It does not really matter if the actual TLS1.2 failure triggers the exception or you manually throw it from ensureSSLPayload(), the driver behavior for retry logic will remain the same.

I built a jar that also checks for the exception.getCause() message and retries, would you be able to test it and verify if the driver retries in case of intermittent TLS1.2 issue with JLINKED image?
Issue879_jar.zip

@martinm1000
Copy link
Author

@ulvii that's interesting. In my case TransportContex.fatal did go to TransportContext.java:293 which is the "unlikely, but just in case." that throw alert.createSSLException("Unexpected rethrowing", cause);

A real test with your build did correctly retry !

This time I can see FINE: Connection failed during SSL handshake. Retrying due to an intermittent TLS 1.2 failure issue. Retry attempt = 1
in the logs.

This was done with:

openjdk 11.0.1 2018-10-16
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.1+13)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.1+13, mixed mode)
jlink.exe --compress=2 --add-modules java.logging,java.naming,java.security.jgss,java.sql,java.transaction.xa,java.xml --output runtime
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream ensureSSLPayload
FINEST: TDSChannel (ConnectionID:82) (SSLHandshakeInputStream): Reading first packet of SSL handshake response
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSReader readPacket
FINER: TDSReader@163 (ConnectionID:82 ClientConnectionId: 75eff6d4-248a-48f2-baba-1c14f50dadb4) Premature EOS in response. packetNum:1 headerBytesRead:0
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.SQLServerException logException
FINE: *** SQLException:ConnectionID:82 ClientConnectionId: 75eff6d4-248a-48f2-baba-1c14f50dadb4 com.microsoft.sqlserver.jdbc.SQLServerException: SQL Server returned an incomplete response. The connection has been closed. ClientConnectionId:75eff6d4-248a-48f2-baba-1c14f50dadb4 SQL Server returned an incomplete response. The connection has been closed. ClientConnectionId:75eff6d4-248a-48f2-baba-1c14f50dadb4
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.SQLServerException logException
FINE: com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2826)com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2815)com.microsoft.sqlserver.jdbc.TDSReader.readPacket(IOBuffer.java:6376)com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.ensureSSLPayload(IOBuffer.java:783)com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.readInternal(IOBuffer.java:836)com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.read(IOBuffer.java:829)com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.readInternal(IOBuffer.java:999)com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.read(IOBuffer.java:989)java.base/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:448)java.base/sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:165)java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:108)java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1152)java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1063)java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:402)com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1756)com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2391)com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2042)com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1889)com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1120)com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:700)java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)java.sql/java.sql.DriverManager.getConnection(DriverManager.java:251)TriggerSSLFailure.main(TriggerSSLFailure.java:38)
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.SQLServerConnection:82 close
FINER: ENTRY
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel disableSSL
FINER: TDSChannel (ConnectionID:82) Disabling SSL...
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel disableSSL
FINEST: TDSChannel (ConnectionID:82) Rewiring proxy streams for SSL socket close
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel disableSSL
FINER: TDSChannel (ConnectionID:82) Closing SSL socket
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel$ProxyOutputStream writeInternal
FINEST: com.microsoft.sqlserver.jdbc.TDSChannel$ProxyOutputStream@5b799640 Writing 31 bytes
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel$ProxyOutputStream flush
FINEST: com.microsoft.sqlserver.jdbc.TDSChannel$ProxyOutputStream@5b799640 Flushing
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel$ProxyOutputStream writeInternal
FINEST: com.microsoft.sqlserver.jdbc.TDSChannel$ProxyOutputStream@5b799640 Writing 31 bytes
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel$ProxyOutputStream flush
FINEST: com.microsoft.sqlserver.jdbc.TDSChannel$ProxyOutputStream@5b799640 Flushing
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream readInternal
FINEST: com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream@6cb107fd Reading 5 bytes
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream readInternal
FINEST: com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream@6cb107fd Read -1 bytes
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel disableSSL
FINER: TDSChannel (ConnectionID:82) SSL disabled
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel close
FINEST: TDSChannel (ConnectionID:82): Closing inputStream...
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel close
FINEST: TDSChannel (ConnectionID:82): Closing outputStream...
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel close
FINER: TDSChannel (ConnectionID:82): Closing TCP socket...
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.SQLServerConnection:82 close
FINER: RETURN
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream ensureSSLPayload
FINER: TDSChannel (ConnectionID:82) (SSLHandshakeInputStream): Reading response packet threw exception:SQL Server returned an incomplete response. The connection has been closed. ClientConnectionId:75eff6d4-248a-48f2-baba-1c14f50dadb4
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream readInternal
FINER: com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream@6cb107fd SQL Server returned an incomplete response. The connection has been closed. ClientConnectionId:75eff6d4-248a-48f2-baba-1c14f50dadb4
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream readInternal
FINER: com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream@6cb107fd Reading bytes threw exception:SQL Server returned an incomplete response. The connection has been closed. ClientConnectionId:75eff6d4-248a-48f2-baba-1c14f50dadb4
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel enableSSL
FINER: Unexpected rethrowing
javax.net.ssl.SSLProtocolException: Unexpected rethrowing
	at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:126)
==>	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:293)
	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:264)
	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:259)
	at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:137)
	at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1152)
	at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1063)
	at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:402)
	at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1756)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2391)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2042)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1889)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1120)
	at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:700)
	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)
	at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:251)
	at TriggerSSLFailure.main(TriggerSSLFailure.java:38)
Caused by: java.io.IOException: SQL Server returned an incomplete response. The connection has been closed. ClientConnectionId:75eff6d4-248a-48f2-baba-1c14f50dadb4
	at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.ensureSSLPayload(IOBuffer.java:786)
	at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.readInternal(IOBuffer.java:836)
	at com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.read(IOBuffer.java:829)
	at com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.readInternal(IOBuffer.java:999)
	at com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.read(IOBuffer.java:989)
	at java.base/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:448)
	at java.base/sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:165)
	at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:108)
	... 12 more

Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel enableSSL
FINER: java.security path: C:\Temp\SSLFail\runtime\lib\security
Security providers: [SUN version 11, SunRsaSign version 11, SunJSSE version 11, SunJCE version 11, SunJGSS version 11, SunSASL version 11, JdkLDAP version 11]
SSLContext provider info: Sun JSSE provider(PKCS12, SunX509/PKIX key/trust factories, SSLv3/TLSv1/TLSv1.1/TLSv1.2/TLSv1.3/DTLSv1.0/DTLSv1.2)
SSLContext provider services:
[SunJSSE: KeyFactory.RSA -> sun.security.rsa.RSAKeyFactory$Legacy
  aliases: [1.2.840.113549.1.1, OID.1.2.840.113549.1.1]
, SunJSSE: KeyPairGenerator.RSA -> sun.security.rsa.RSAKeyPairGenerator$Legacy
  aliases: [1.2.840.113549.1.1, OID.1.2.840.113549.1.1]
, SunJSSE: Signature.MD2withRSA -> sun.security.rsa.RSASignature$MD2withRSA
  aliases: [1.2.840.113549.1.1.2, OID.1.2.840.113549.1.1.2]
, SunJSSE: Signature.MD5withRSA -> sun.security.rsa.RSASignature$MD5withRSA
  aliases: [1.2.840.113549.1.1.4, OID.1.2.840.113549.1.1.4]
, SunJSSE: Signature.SHA1withRSA -> sun.security.rsa.RSASignature$SHA1withRSA
  aliases: [1.2.840.113549.1.1.5, OID.1.2.840.113549.1.1.5, 1.3.14.3.2.29, OID.1.3.14.3.2.29]
, SunJSSE: Signature.MD5andSHA1withRSA -> sun.security.ssl.RSASignature
, SunJSSE: KeyManagerFactory.SunX509 -> sun.security.ssl.KeyManagerFactoryImpl$SunX509
, SunJSSE: KeyManagerFactory.NewSunX509 -> sun.security.ssl.KeyManagerFactoryImpl$X509
  aliases: [PKIX]
, SunJSSE: TrustManagerFactory.SunX509 -> sun.security.ssl.TrustManagerFactoryImpl$SimpleFactory
, SunJSSE: TrustManagerFactory.PKIX -> sun.security.ssl.TrustManagerFactoryImpl$PKIXFactory
  aliases: [SunPKIX, X509, X.509]
, SunJSSE: SSLContext.TLSv1 -> sun.security.ssl.SSLContextImpl$TLS10Context
  aliases: [SSLv3]
, SunJSSE: SSLContext.TLSv1.1 -> sun.security.ssl.SSLContextImpl$TLS11Context
, SunJSSE: SSLContext.TLSv1.2 -> sun.security.ssl.SSLContextImpl$TLS12Context
, SunJSSE: SSLContext.TLSv1.3 -> sun.security.ssl.SSLContextImpl$TLS13Context
, SunJSSE: SSLContext.TLS -> sun.security.ssl.SSLContextImpl$TLSContext
  aliases: [SSL]
, SunJSSE: SSLContext.DTLSv1.0 -> sun.security.ssl.SSLContextImpl$DTLS10Context
, SunJSSE: SSLContext.DTLSv1.2 -> sun.security.ssl.SSLContextImpl$DTLS12Context
, SunJSSE: SSLContext.DTLS -> sun.security.ssl.SSLContextImpl$DTLSContext
, SunJSSE: SSLContext.Default -> sun.security.ssl.SSLContextImpl$DefaultSSLContext
, SunJSSE: KeyStore.PKCS12 -> sun.security.pkcs12.PKCS12KeyStore
]
java.ext.dirs: null
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.SQLServerException logException
FINE: *** SQLException:ConnectionID:82 ClientConnectionId: 75eff6d4-248a-48f2-baba-1c14f50dadb4 com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "Unexpected rethrowing". The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "Unexpected rethrowing".
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.SQLServerException logException
FINE: com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2826)com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1834)com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2391)com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2042)com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1889)com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1120)com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:700)java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)java.sql/java.sql.DriverManager.getConnection(DriverManager.java:251)TriggerSSLFailure.main(TriggerSSLFailure.java:38)
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.SQLServerConnection:82 close
FINER: ENTRY
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel close
FINEST: TDSChannel (ConnectionID:82): Closing inputStream...
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel close
FINEST: TDSChannel (ConnectionID:82): Closing outputStream...
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel close
FINER: TDSChannel (ConnectionID:82): Closing TCP socket...
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.SQLServerConnection:82 close
FINER: RETURN
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.SQLServerConnection:82 close
FINER: ENTRY
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel close
FINEST: TDSChannel (ConnectionID:82): Closing inputStream...
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel close
FINEST: TDSChannel (ConnectionID:82): Closing outputStream...
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.TDSChannel close
FINER: TDSChannel (ConnectionID:82): Closing TCP socket...
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.SQLServerConnection:82 close
FINER: RETURN
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.SQLServerConnection connect
FINE: Connection failed during SSL handshake. Retrying due to an intermittent TLS 1.2 failure issue. Retry attempt = 1.
Nov 16, 2018 10:12:32 AM com.microsoft.sqlserver.jdbc.SQLServerConnection login

@ulvii
Copy link
Contributor

ulvii commented Nov 16, 2018

Hi @martinm1000 ,

Thank you for testing the build. I created a PR, please feel free to review it.

@cheenamalhotra cheenamalhotra added this to In progress in MSSQL JDBC Nov 21, 2018
@ulvii
Copy link
Contributor

ulvii commented Nov 27, 2018

#882 merged.

@ulvii ulvii closed this as completed Nov 27, 2018
MSSQL JDBC automation moved this from In progress to Closed Issues Nov 27, 2018
@muhammedOzbilici
Copy link

muhammedOzbilici commented Dec 18, 2019

I am having same problem too.
Driver version -> mssql- 7.4.1.jre8

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:5fb87e9c-db2e-498c-b480-2d4aebae622a".

@martinm1000
Copy link
Author

@muhammedOzbilici I don't think this is the same problem; Yours is "SQL Server did not return a response" which means something else (not sure what!)

@muhammedOzbilici
Copy link

@muhammedOzbilici I don't think this is the same problem; Yours is "SQL Server did not return a response" which means something else (not sure what!)

But, is it not related to SSL ? If it's not then, which configuration I have to check on Database side ?

@ulvii
Copy link
Contributor

ulvii commented Dec 19, 2019

Hi @muhammedOzbilici ,
Please go through the closed issues, there might already be a solution provided for your problem.

@italin40
Copy link

@muhammedOzbilici I don't think this is the same problem; Yours is "SQL Server did not return a response" which means something else (not sure what!)

But, is it not related to SSL ? If it's not then, which configuration I have to check on Database side ?

I have the same problem

@italin40
Copy link

янв 16, 2020 8:00:01 PM com.microsoft.sqlserver.jdbc.SQLServerDriver:1 connect
FINER: ENTRY Arguments not traced.
янв 16, 2020 8:00:01 PM com.microsoft.sqlserver.jdbc.Util parseUrl
FINE: Property:serverName Value:192.168.192.137
янв 16, 2020 8:00:01 PM com.microsoft.sqlserver.jdbc.Util parseUrl
FINE: Property:portNumber Value:1433
янв 16, 2020 8:00:01 PM com.microsoft.sqlserver.jdbc.Util parseUrl
FINE: Property:databaseName Value:docflow
янв 16, 2020 8:00:01 PM com.microsoft.sqlserver.jdbc.Util parseUrl
FINE: Property:sslProtocol Value:TLSv1.2
янв 16, 2020 8:00:01 PM com.microsoft.sqlserver.jdbc.SQLServerColumnEncryptionCertificateStoreProvider SQLServerColumnEncryptionCertificateStoreProvider
FINER: ENTRY
янв 16, 2020 8:00:01 PM com.microsoft.sqlserver.jdbc.SQLServerConnection
FINE: ConnectionID:1 created by (SQLServerDriver:1)
янв 16, 2020 8:00:01 PM com.microsoft.sqlserver.jdbc.SQLServerConnection login
FINER: ConnectionID:1 Start time: 1579190401824 Time out time: 1579190416824 Timeout Unit Interval: 1875
янв 16, 2020 8:00:01 PM com.microsoft.sqlserver.jdbc.SQLServerConnection login
FINE: ConnectionID:1 This attempt server name: 192.168.192.137 port: 1433 InstanceName: null useParallel: false
янв 16, 2020 8:00:01 PM com.microsoft.sqlserver.jdbc.SQLServerConnection login
FINE: ConnectionID:1 This attempt endtime: 1579190403699
янв 16, 2020 8:00:01 PM com.microsoft.sqlserver.jdbc.SQLServerConnection login
FINE: ConnectionID:1 This attempt No: 0
янв 16, 2020 8:00:01 PM com.microsoft.sqlserver.jdbc.SQLServerConnection connectHelper
FINE: ConnectionID:1 Connecting with server: 192.168.192.137 port: 1433 Timeout slice: 1870 Timeout Full: 15
янв 16, 2020 8:00:01 PM com.microsoft.sqlserver.jdbc.TDSChannel open
FINER: TDSChannel (ConnectionID:1): Opening TCP socket...
янв 16, 2020 8:00:01 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
FINER: ConnectionID:1 ClientConnectionId: bf2e7c61-8f0d-4913-a01e-a77de1761c80 Requesting encryption level:OFF
янв 16, 2020 8:00:01 PM com.microsoft.sqlserver.jdbc.TDSChannel logPacket
FINEST: /192.168.192.136:51284 SPID:0 ConnectionID:1 ClientConnectionId: bf2e7c61-8f0d-4913-a01e-a77de1761c80 Prelogin request
12 01 00 43 00 00 00 00 00 00 10 00 06 01 00 16 ...C............
00 01 05 00 17 00 24 FF 00 00 00 00 00 00 00 61 ......$........a
7C 2E BF 0D 8F 13 49 A0 1E A7 7D E1 76 1C 80 00 |.....I...}.v...
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 ...
янв 16, 2020 8:00:01 PM com.microsoft.sqlserver.jdbc.TDSChannel logPacket
FINEST: /192.168.192.136:51284 SPID:0 ConnectionID:1 ClientConnectionId: bf2e7c61-8f0d-4913-a01e-a77de1761c80 Prelogin response
04 01 00 1A 00 00 01 00 00 00 0B 00 06 01 00 11 ................
00 01 FF 0A 00 06 40 00 00 00 ......@...
янв 16, 2020 8:00:01 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
FINE: ConnectionID:1 ClientConnectionId: bf2e7c61-8f0d-4913-a01e-a77de1761c80 Server returned major version:10
янв 16, 2020 8:00:01 PM com.microsoft.sqlserver.jdbc.SQLServerConnection Prelogin
FINER: ConnectionID:1 ClientConnectionId: bf2e7c61-8f0d-4913-a01e-a77de1761c80 Negotiated encryption level:OFF
янв 16, 2020 8:00:01 PM com.microsoft.sqlserver.jdbc.TDSChannel enableSSL
FINER: TDSChannel (ConnectionID:1) Enabling SSL...
янв 16, 2020 8:00:01 PM com.microsoft.sqlserver.jdbc.TDSChannel enableSSL
FINER: TDSChannel (ConnectionID:1) SSL handshake will trust any certificate
янв 16, 2020 8:00:01 PM com.microsoft.sqlserver.jdbc.TDSChannel enableSSL
FINEST: TDSChannel (ConnectionID:1) Getting TLS or better SSL context
янв 16, 2020 8:00:02 PM com.microsoft.sqlserver.jdbc.TDSChannel enableSSL
FINEST: TDSChannel (ConnectionID:1) Initializing SSL context
янв 16, 2020 8:00:02 PM com.microsoft.sqlserver.jdbc.TDSChannel enableSSL
FINEST: TDSChannel (ConnectionID:1) Creating SSL socket
янв 16, 2020 8:00:02 PM com.microsoft.sqlserver.jdbc.TDSChannel$ProxySocket getInputStream
FINEST: TDSChannel (ConnectionID:1) (ProxySocket): Getting input stream
янв 16, 2020 8:00:02 PM com.microsoft.sqlserver.jdbc.TDSChannel$ProxySocket getOutputStream
FINEST: TDSChannel (ConnectionID:1) (ProxySocket): Getting output stream
янв 16, 2020 8:00:02 PM com.microsoft.sqlserver.jdbc.TDSChannel enableSSL
FINER: TDSChannel (ConnectionID:1) Starting SSL handshake
янв 16, 2020 8:00:02 PM com.microsoft.sqlserver.jdbc.TDSChannel$ProxyOutputStream writeInternal
FINEST: com.microsoft.sqlserver.jdbc.TDSChannel$ProxyOutputStream@174d20a Writing 198 bytes
янв 16, 2020 8:00:02 PM com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeOutputStream writeInternal
FINEST: TDSChannel (ConnectionID:1) (SSLHandshakeOutputStream): Starting new TDS packet...
янв 16, 2020 8:00:02 PM com.microsoft.sqlserver.jdbc.TDSWriter writeBytes
FINEST: TDSWriter@15380c2 (ConnectionID:1) Writing 8 bytes
янв 16, 2020 8:00:02 PM com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeOutputStream writeInternal
FINEST: TDSChannel (ConnectionID:1) (SSLHandshakeOutputStream): Writing 198 bytes...
янв 16, 2020 8:00:02 PM com.microsoft.sqlserver.jdbc.TDSWriter writeBytes
FINEST: TDSWriter@15380c2 (ConnectionID:1) Writing 198 bytes
янв 16, 2020 8:00:02 PM com.microsoft.sqlserver.jdbc.TDSChannel$ProxyOutputStream flush
FINEST: com.microsoft.sqlserver.jdbc.TDSChannel$ProxyOutputStream@174d20a Flushing
янв 16, 2020 8:00:02 PM com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeOutputStream flush
FINEST: TDSChannel (ConnectionID:1) (SSLHandshakeOutputStream): Ignored a request to flush the stream
янв 16, 2020 8:00:02 PM com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream readInternal
FINEST: com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream@d2e7d9 Reading 5 bytes
янв 16, 2020 8:00:02 PM com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream readInternal
FINEST: TDSChannel (ConnectionID:1) (SSLHandshakeInputStream): Reading 5 bytes...
янв 16, 2020 8:00:02 PM com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream ensureSSLPayload
FINEST: TDSChannel (ConnectionID:1) (SSLHandshakeInputStream): No handshake response bytes available. Flushing SSL handshake output stream.
янв 16, 2020 8:00:02 PM com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeOutputStream endMessage
FINEST: TDSChannel (ConnectionID:1) (SSLHandshakeOutputStream): Finishing TDS message
янв 16, 2020 8:00:02 PM com.microsoft.sqlserver.jdbc.TDSWriter endMessage
FINEST: TDSWriter@15380c2 (ConnectionID:1) Finishing TDS message
янв 16, 2020 8:00:02 PM com.microsoft.sqlserver.jdbc.TDSChannel logPacket
FINEST: /192.168.192.136:51284 SPID:0 TDSWriter@15380c2 (ConnectionID:1) sending packet (206 bytes)
12 01 00 CE 00 00 01 00 16 03 03 00 C1 01 00 00 ................
BD 03 03 5E 20 88 82 02 EA 52 77 61 CB 24 8D 7A ...^ ....Rwa.$.z
7E 2B 61 CE B5 EB 2A 9A A7 3F 63 0C D5 BC 34 37 ~+a.....?c...47
B4 6B 6B 00 00 56 C0 24 C0 28 00 3D C0 26 C0 2A .kk..V.$.(.=.&.

00 6B 00 6A C0 0A C0 14 00 35 C0 05 C0 0F 00 39 .k.j.....5.....9
00 38 C0 23 C0 27 00 3C C0 25 C0 29 00 67 00 40 .8.#.'.<.%.).g.@
C0 09 C0 13 00 2F C0 04 C0 0E 00 33 00 32 C0 2C ...../.....3.2.,
C0 2B C0 30 00 9D C0 2E C0 32 00 9F 00 A3 C0 2F .+.0.....2...../
00 9C C0 2D C0 31 00 9E 00 A2 00 FF 01 00 00 3E ...-.1.........>
00 0A 00 16 00 14 00 17 00 18 00 19 00 09 00 0A ................
00 0B 00 0C 00 0D 00 0E 00 16 00 0B 00 02 01 00 ................
00 0D 00 16 00 14 06 03 06 01 05 03 05 01 04 03 ................
04 01 04 02 02 03 02 01 02 02 00 17 00 00 ..............
янв 16, 2020 8:00:02 PM com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream ensureSSLPayload
FINEST: TDSChannel (ConnectionID:1) (SSLHandshakeInputStream): Reading first packet of SSL handshake response
янв 16, 2020 8:00:02 PM com.microsoft.sqlserver.jdbc.TDSReader readPacket
FINER: TDSReader@1 (ConnectionID:1 ClientConnectionId: bf2e7c61-8f0d-4913-a01e-a77de1761c80) Premature EOS in response. packetNum:0 headerBytesRead:0
янв 16, 2020 8:00:02 PM com.microsoft.sqlserver.jdbc.SQLServerException logException
FINE: *** SQLException:ConnectionID:1 ClientConnectionId: bf2e7c61-8f0d-4913-a01e-a77de1761c80 com.microsoft.sqlserver.jdbc.SQLServerException: SQL Server не вернул ответ. Соединение было закрыто. ClientConnectionId:bf2e7c61-8f0d-4913-a01e-a77de1761c80 SQL Server не вернул ответ. Соединение было закрыто. ClientConnectionId:bf2e7c61-8f0d-4913-a01e-a77de1761c80
янв 16, 2020 8:00:02 PM com.microsoft.sqlserver.jdbc.SQLServerException logException

@italin40
Copy link

one of the solutions

@italin40
Copy link

@muhammedOzbilici I don't think this is the same problem; Yours is "SQL Server did not return a response" which means something else (not sure what!)

But, is it not related to SSL ? If it's not then, which configuration I have to check on Database side ?

one of the solutions

@muhammedOzbilici
Copy link

@muhammedOzbilici I don't think this is the same problem; Yours is "SQL Server did not return a response" which means something else (not sure what!)

But, is it not related to SSL ? If it's not then, which configuration I have to check on Database side ?

one of the solutions

thanks, I will look into it.

@mshareski
Copy link

This is an older thread but I wanted to leave this here in case it helps somebody scouring the Internet....

I was getting this error in an AWS Lambda function and found it was caused by giving the function too little memory. I bumped it up from 128MB to 512MB (probably overkill) and it works now. "The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption" was pretty misleading but it turned out to be too little memory.

@IndrajeetTech2020
Copy link

Currently I am getting this issue

com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: No appropriate protocol (protocol is disabled or cipher suites are inappropriate).
at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1509)

I am trying to connect to mssql server from java dynamic web project.Any help is appreciable

@akhilnambiar29
Copy link

We fixed this issue by enforcing sslProtocol=TLSv1.2; in our database connection string.

@anhduy157
Copy link

anhduy157 commented Jul 31, 2023

most likely the local version of sql server is not supported. like I fixed it by going from version 12.0.2000 to 12.0.5000
Sql2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
MSSQL JDBC
  
Closed Issues
Development

No branches or pull requests

9 participants