milesibastos / jTDS

jTDS JDBC Driver
http://jtds.sourceforge.net/
GNU Lesser General Public License v2.1
81 stars 46 forks source link

jTDS/MSSQL/SSL #15

Open xvfaithvx opened 4 years ago

xvfaithvx commented 4 years ago

I am relatively sure this 'issue' is my lack of understanding but hope the community may be able to help. I've clicked/read/tried every existing link on the topic without success. I have tried using different versions of jTDS though right now I'm trying with 1.3.3. Thank you in advance for any help you can provide!!

I have an Android app that connects to a SQL DB hosted on Amazon RDS. Without using SSL it works great; no problems. Below is the connection string:

            Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance();
            String connectionstring = "jdbc:jtds:sqlserver://" + servername + "/" + dbname + ";" +
                    "user=" + userid + ";password=" + pwd + ";";

Now I want to enable SSL. I made the change on the MSSQL server parameter and I am able to connect using Management Studio and .NET apps. However, I have not been able to connect via my Android app using jtds. Initially the only change I am making is to add ssl=require to the connection string.

Based on some different threads I've read I have tried adding the following line to the gradle.properties file of the project with no change:

org.gradle.jvmargs=-Djsse.enableCBCProtection=false

No matter what I do I get the same error.

_"Network error IOException: SSL handshak_e aborted: ssl=0xa67a6cc0: I/O error during system call, Broken pipe"__

This is what the stacktrace prints:

W/System.err: java.sql.SQLException: Network error IOException: SSL handshake aborted: ssl=0xa67bdcc0: I/O error during system call, Broken pipe at net.sourceforge.jtds.jdbc.JtdsConnection.(JtdsConnection.java:437) at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184) at java.sql.DriverManager.getConnection(DriverManager.java:569) at java.sql.DriverManager.getConnection(DriverManager.java:237) W/System.err: at com.bluestarsolutions.caylix_time.DBRemote.openConnection(DBRemote.java:412) at com.bluestarsolutions.caylix_time.DBRemote.DownloadInfo(DBRemote.java:47) at com.bluestarsolutions.caylix_time.MainActivity$6.run(MainActivity.java:585) at java.lang.Thread.run(Thread.java:764) Caused by: javax.net.ssl.SSLHandshakeException: SSL handshake aborted: ssl=0xa67bdcc0: I/O error during system call, Broken pipe W/System.err: at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method) at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:351) at net.sourceforge.jtds.ssl.SocketFactories$TdsTlsSocketFactory.createSocket(SocketFactories.java:101) at net.sourceforge.jtds.jdbc.SharedSocket.enableEncryption(SharedSocket.java:330) at net.sourceforge.jtds.jdbc.TdsCore.negotiateSSL(TdsCore.java:577) W/System.err: at net.sourceforge.jtds.jdbc.JtdsConnection.(JtdsConnection.java:365) ... 7 more

morimoriysmoon commented 3 years ago

@xvfaithvx I think cipher/CA Certs on your Android platform is too old to support SSL connetion to MS SQL Server.