{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/mssql-jdbc/issues/879","repository_url":"https://api.github.com/repos/Microsoft/mssql-jdbc","labels_url":"https://api.github.com/repos/Microsoft/mssql-jdbc/issues/879/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/mssql-jdbc/issues/879/comments","events_url":"https://api.github.com/repos/Microsoft/mssql-jdbc/issues/879/events","html_url":"https://github.com/Microsoft/mssql-jdbc/issues/879","id":380398770,"node_id":"MDU6SXNzdWUzODAzOTg3NzA=","number":879,"title":"The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: \"Unexpected rethrowing\".","user":{"login":"martinm1000","id":3790866,"node_id":"MDQ6VXNlcjM3OTA4NjY=","avatar_url":"https://avatars2.githubusercontent.com/u/3790866?v=4","gravatar_id":"","url":"https://api.github.com/users/martinm1000","html_url":"https://github.com/martinm1000","followers_url":"https://api.github.com/users/martinm1000/followers","following_url":"https://api.github.com/users/martinm1000/following{/other_user}","gists_url":"https://api.github.com/users/martinm1000/gists{/gist_id}","starred_url":"https://api.github.com/users/martinm1000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martinm1000/subscriptions","organizations_url":"https://api.github.com/users/martinm1000/orgs","repos_url":"https://api.github.com/users/martinm1000/repos","events_url":"https://api.github.com/users/martinm1000/events{/privacy}","received_events_url":"https://api.github.com/users/martinm1000/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"ulvii","id":22036901,"node_id":"MDQ6VXNlcjIyMDM2OTAx","avatar_url":"https://avatars3.githubusercontent.com/u/22036901?v=4","gravatar_id":"","url":"https://api.github.com/users/ulvii","html_url":"https://github.com/ulvii","followers_url":"https://api.github.com/users/ulvii/followers","following_url":"https://api.github.com/users/ulvii/following{/other_user}","gists_url":"https://api.github.com/users/ulvii/gists{/gist_id}","starred_url":"https://api.github.com/users/ulvii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ulvii/subscriptions","organizations_url":"https://api.github.com/users/ulvii/orgs","repos_url":"https://api.github.com/users/ulvii/repos","events_url":"https://api.github.com/users/ulvii/events{/privacy}","received_events_url":"https://api.github.com/users/ulvii/received_events","type":"User","site_admin":false},"assignees":[{"login":"ulvii","id":22036901,"node_id":"MDQ6VXNlcjIyMDM2OTAx","avatar_url":"https://avatars3.githubusercontent.com/u/22036901?v=4","gravatar_id":"","url":"https://api.github.com/users/ulvii","html_url":"https://github.com/ulvii","followers_url":"https://api.github.com/users/ulvii/followers","following_url":"https://api.github.com/users/ulvii/following{/other_user}","gists_url":"https://api.github.com/users/ulvii/gists{/gist_id}","starred_url":"https://api.github.com/users/ulvii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ulvii/subscriptions","organizations_url":"https://api.github.com/users/ulvii/orgs","repos_url":"https://api.github.com/users/ulvii/repos","events_url":"https://api.github.com/users/ulvii/events{/privacy}","received_events_url":"https://api.github.com/users/ulvii/received_events","type":"User","site_admin":false}],"milestone":null,"comments":16,"created_at":"2018-11-13T20:00:46Z","updated_at":"2018-11-15T16:31:47Z","closed_at":null,"author_association":"NONE","body":"## Driver version\r\nmssql-jdbc-7.1.2.jre11\r\nmssql-jdbc-7.0.0.jre10 ( i think I got the problem with this one too)\r\n\r\n## Problem / Question\r\n\r\nI'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.\r\n\r\nI 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.\r\n\r\nCan 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 ?\r\n\r\n```java\r\ncom.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\".\r\n        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2826)\r\n        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1829)\r\n        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2391)\r\n        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2042)\r\n        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1889)\r\n        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1120)\r\n        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:700)\r\n        at java.sql/java.sql.DriverManager.getConnection(Unknown Source)\r\n```\r\n```java\r\nCaused by: javax.net.ssl.SSLProtocolException: Unexpected rethrowing\r\n        at java.base/sun.security.ssl.Alert.createSSLException(Unknown Source)\r\n        at java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)\r\n        at java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)\r\n        at java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)\r\n        at java.base/sun.security.ssl.SSLTransport.decode(Unknown Source)\r\n        at java.base/sun.security.ssl.SSLSocketImpl.decode(Unknown Source)\r\n        at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(Unknown Source)\r\n        at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)\r\n        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1756)\r\n        ... 41 more\r\nCaused by: java.io.IOException: SQL Server returned an incomplete response. The connection has been closed. ClientConnectionId:b9ef7c65-28e5-4858-9cc1-642eaa2725d1\r\n        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.ensureSSLPayload(IOBuffer.java:786)\r\n        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.readInternal(IOBuffer.java:836)\r\n        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.TDSChannel$SSLHandshakeInputStream.read(IOBuffer.java:829)\r\n        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.readInternal(IOBuffer.java:999)\r\n        at com.microsoft.sqlserver.jdbc@7.1.2.jre11-preview/com.microsoft.sqlserver.jdbc.TDSChannel$ProxyInputStream.read(IOBuffer.java:989)\r\n        at java.base/sun.security.ssl.SSLSocketInputRecord.read(Unknown Source)\r\n        at java.base/sun.security.ssl.SSLSocketInputRecord.decode(Unknown Source)\r\n        ... 46 more\r\n```"},"comment":{"url":"https://api.github.com/repos/Microsoft/mssql-jdbc/issues/comments/439102732","html_url":"https://github.com/Microsoft/mssql-jdbc/issues/879#issuecomment-439102732","issue_url":"https://api.github.com/repos/Microsoft/mssql-jdbc/issues/879","id":439102732,"node_id":"MDEyOklzc3VlQ29tbWVudDQzOTEwMjczMg==","user":{"login":"martinm1000","id":3790866,"node_id":"MDQ6VXNlcjM3OTA4NjY=","avatar_url":"https://avatars2.githubusercontent.com/u/3790866?v=4","gravatar_id":"","url":"https://api.github.com/users/martinm1000","html_url":"https://github.com/martinm1000","followers_url":"https://api.github.com/users/martinm1000/followers","following_url":"https://api.github.com/users/martinm1000/following{/other_user}","gists_url":"https://api.github.com/users/martinm1000/gists{/gist_id}","starred_url":"https://api.github.com/users/martinm1000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martinm1000/subscriptions","organizations_url":"https://api.github.com/users/martinm1000/orgs","repos_url":"https://api.github.com/users/martinm1000/repos","events_url":"https://api.github.com/users/martinm1000/events{/privacy}","received_events_url":"https://api.github.com/users/martinm1000/received_events","type":"User","site_admin":false},"created_at":"2018-11-15T16:31:47Z","updated_at":"2018-11-15T16:31:47Z","author_association":"NONE","body":"Well I have no idea. I suppose I'll go with SSLv1 and hope its support never goes away...\r\nSomeone else will have to look/test this, I don't see what else I can do.\r\n\r\njava.base/sun.security.ssl TransportContext:293\r\n```java\r\n// Note: close_notify is not delivered via fatal() methods.\r\n    void fatal(Alert alert, String diagnostic,\r\n            boolean recvFatalAlert, Throwable cause) throws SSLException {\r\n        // If we've already shutdown because of an error, there is nothing we\r\n        // can do except rethrow the exception.\r\n        //\r\n        // Most exceptions seen here will be SSLExceptions. We may find the\r\n        // occasional Exception which hasn't been converted to a SSLException,\r\n        // so we'll do it here.\r\n        if (closeReason != null) {\r\n            if (cause == null) {\r\n                if (SSLLogger.isOn && SSLLogger.isOn(\"ssl\")) {\r\n                    SSLLogger.warning(\r\n                            \"Closed transport, general or untracked problem\");\r\n                }\r\n                throw alert.createSSLException(\r\n                        \"Closed transport, general or untracked problem\");\r\n            }\r\n\r\n            if (cause instanceof SSLException) {\r\n                throw (SSLException)cause;\r\n            } else {    // unlikely, but just in case.\r\n                if (SSLLogger.isOn && SSLLogger.isOn(\"ssl\")) {\r\n                    SSLLogger.warning(\r\n                            \"Closed transport, unexpected rethrowing\", cause);\r\n                }\r\n                throw alert.createSSLException(\"Unexpected rethrowing\", cause);\r\n            }\r\n        }\r\n```\r\n\r\n```java\r\nCaused by: javax.net.ssl.SSLProtocolException: Unexpected rethrowing\r\n        at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:126)\r\n        at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:293)\r\n        at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:264)\r\n        at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:259)\r\n        at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:137)\r\n        at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1152)\r\n        at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1063)\r\n        at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:402)\r\n        at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1756)\r\n```"}}
{"actor":{"display_login":"martinm1000"}}