从昨天开始,我无法从JBoss EAP 6.2连接到本地开发机器上的MicroSoft SQLServer(v11.1.3000.0)。 SQLServer现在想要使用SSL进行连接。
我得到以下异常:
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "java.lang.RuntimeException: Could not generate DH keypair". ClientConnectionId:da0dbbf4-33a0-45ac-9885-fa1e31c47c6e
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 org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:260)
... 28 more
Caused by: javax.net.ssl.SSLException: java.lang.RuntimeException: Could not generate DH keypair
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:190) [jsse.jar:1.6]
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1747) [jsse.jar:1.6]
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1708) [jsse.jar:1.6]
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1691) [jsse.jar:1.6]
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1222) [jsse.jar:1.6]
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1199) [jsse.jar:1.6]
at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1618)
... 33 more
Caused by: java.lang.RuntimeException: Could not generate DH keypair
at com.sun.net.ssl.internal.ssl.DHCrypt.<init>(DHCrypt.java:114) [jsse.jar:1.6]
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverKeyExchange(ClientHandshaker.java:559) [jsse.jar:1.6]
at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:186) [jsse.jar:1.6]
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:593) [jsse.jar:1.6]
at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:529) [jsse.jar:1.6]
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:943) [jsse.jar:1.6]
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1188) [jsse.jar:1.6]
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1215) [jsse.jar:1.6]
... 35 more
Caused by: java.security.InvalidAlgorithmParameterException: Prime size must be multiple of 64, and can only range from 512 to 1024 (inclusive)
at com.sun.crypto.provider.DHKeyPairGenerator.initialize(DashoA13*..) [sunjce_provider.jar:1.6]
at java.security.KeyPairGenerator$Delegate.initialize(KeyPairGenerator.java:627) [rt.jar:1.6.0_45]
at com.sun.net.ssl.internal.ssl.DHCrypt.<init>(DHCrypt.java:107) [jsse.jar:1.6]
... 42 more
当我在测试环境中连接到SQLServer(11.0.2100.60)时,一切正常。
我做了以下事情: - 确保我的Java 6 JRE中有正确的JCE库 - 更新了sqljdbc4.jar - 阅读:Java: Why does SSL handshake give 'Could not generate DH keypair' exception?
我没有尝试过上面文章中的解决方法。我宁愿停止SQLServer来驱逐SSL。
如何阻止SQLServer要求SSL连接?或者修复我的配置?这怎么可能发生呢?是否有SQLServer的自动更新?
答案 0 :(得分:5)
今天早上我遇到了同样的问题,一些单元测试开始失败。我注意到我正在使用1.6 JDK编译项目,将其更改为1.7.0_79使问题消失。
不确定问题的根本原因是什么,没有时间进一步调查。
答案 1 :(得分:2)
今天我有同样的问题。连接Java应用程序(周二工作)但今天(星期四)无法使用相同的应用程序。我有自动软件更新的Windows 10,我正在运行Microsoft SQL Server 2014(2014 Express 12.0.2000.8)。我确认了协议(SQL Server配置管理器&gt; SQL Server网络配置&gt; SQLEXPRESS协议(属性)。强制加密=&#34;否&#34;)。我回滚了Windows KB3163018并重新启动了计算机并能够连接。
答案 2 :(得分:2)
此问题与Oracle JDK和美国政府的出口政策有关。
可以在以下位置找到相应的无限JCE文件:http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html
解压zip并替换jre / lib / security中的local_policy.jar,US_export_policy.jar