Cs1.5对战平台:JDK 1.5SSLHandshakeException

我有奇怪的问题,我不能固定。

我有 JDK 1.5 版本和基于 SSL 的通信通过套接字,只需发送和接收字符串数据。

try {
    KeyStore ks = KeyStore.getInstance("JKS");
    ks.load(new FileInputStream(
            "path_to_.jks"),
            "secret_of_jks".toCharArray());
    TrustManagerFactory tmf = TrustManagerFactory
            .getInstance(TrustManagerFactory.getDefaultAlgorithm());
    tmf.init(ks);
    KeyManagerFactory kmf = KeyManagerFactory
            .getInstance(KeyManagerFactory.getDefaultAlgorithm());
    kmf.init(ks, "secret_of_jks".toCharArray());
    SSLContext ctx = SSLContext.getInstance("TLS");
    ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
    Socket s = ctx.getSocketFactory().createSocket("address_of_server", PORT);
    String jsonEx = "json text to send server";
    StringBuilder sb = new StringBuilder();
    sb.append(jsonEx.getBytes().length);
    sb.append("\r\n");
    sb.append(jsonEx);
    PrintWriter writer = new PrintWriter(s.getOutputStream(), true);
    writer.println(sb.toString());
    BufferedReader in =  new BufferedReader(new InputStreamReader(s.getInputStream()));
    System.out.println(in.readLine());
    writer.flush();
} catch (Exception e) {
    e.printStackTrace();
}

当我使用 JDK 1.7 + 一切正常,但是当我切换到 1.6-它抛出javax.net.ssl.SSLException: Connection has been shutdown: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake

我的证书是 2048 加密的,我还安装了 JCE 无限强度管辖权策略http://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html

如果有人感兴趣,这里是完全例外:

记录.net.ssl.SSLException:连接:记录.Lsunplush.LsunioslvaExceptor:记录.LsunioslvaWraph.LsunioslvaWraph.LsunioslvaExceptor:记录.LsunioslvaWraph.SSLsunioslvaRe

ConnectorTest Line 43 is
System.out.println(in.readLine());
Updated
trigger seeding of SecureRandom
done seeding SecureRandom
Allow unsafe renegotiation: false
Allow legacy hello messages: true
Is initial handshake: true
Is secure renegotiation: false
%% No cached client session
*** Hello, TLSv1
RandomCookie:  T: 1439443814 bytes = { 228, 36, 73, 128, 109, 225, 11, 36, 62, 40, 147, 150, 27, 145, 150, 163, 244, 28, 97, 56, 188, 81, 117, 31, 235, 60, 101, 224 }
Session ID:  {}
Cipher Suites: [SSL_RSA_WITH_RC4_128_MD5, SSL_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_DES_CBC_SHA, SSL_DHE_RSA_WITH_DES_CBC_SHA, SSL_DHE_DSS_WITH_DES_CBC_SHA, SSL_RSA_EXPORT_WITH_RC4_40_MD5, SSL_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
Compression Methods:  { 0 }
***
main, WRITE: TLSv1 Handshake, length = 75
main, WRITE: SSLv2 client hello message, length = 101
main, received EOFException: error
main, handling exception: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
main, SEND TLSv1 ALERT:  fatal, description = handshake_failure
main, WRITE: TLSv1 Alert, length = 2
main, called closeSocket()
Update2

我刚刚发现,它们之间的区别是:

有效期自 2016 年 2 月 16 日星期二20:07:36GET 2016 至 2 月 16 日星期四20:07:36GET 20171.7 正确

有效期从 2016 年 2 月 16 日星期二16:07:36T 至 2 月 16 日星期四16:07:36T 20171.6 错误

1

经过大量研究,我发现,没有办法做到这一点,当然,安装无限策略也是丑陋的解决方案。Sun 不建议我们更改策略。解决该问题的最佳方法是,始终保持您的 Java 版本比这个更好。我不得不写在 1.5 上,没有其他机会简单地升级系统,并决定更糟,但唯一的解决方案,当然是在 Java 1.8 + Wildlfy 机器上创建了某种代理服务

0

可能是服务器不支持客户端的 SSL 版本(客户端提供的 SSL 版本太低)。

尝试添加系统属性“javax.net.debug = ssl”,以便在系统输出中获得更好的错误描述。例如:

System.setProperty("javax.net.debug", "ssl");

或添加命令行参数:

-Djavax.net.debug=ssl

为什么要使用较旧的 Java?如果必须使用 1.6,请尝试将其更新为最新的补丁版本。

本站系公益性非盈利分享网址,本文来自用户投稿,不代表边看边学立场,如若转载,请注明出处

(147)
服务器开发需要学什么:Web服务器和开发服务器有什么区别
上一篇
Cod16多人模式:为Blackberry生成COD文件
下一篇

相关推荐

发表评论

登录 后才能评论

评论列表(44条)