事件:
因为调用的接口要升级到 tls1.2协议,但是我的项目环境是JDK1.6,功能多,代码乱不敢升级到JDK1.8.根据网上查到的jdk1.6 支持 tls1.2协议的方法,新建TLSSocketConnectionFactory类并继承SSLSocketFactory。
同时 在 httpsurlconnection.setSSLSocketFactory(new TLSSocketConnectionFactory());
但是运行后报java.io.IOException: Internal TLS error, this could be an attack。如果使用自己实现的X509TrustManager来信任所有证书,则只能用SSLContext,
httpsurlconnection.setSSLSocketFactory(sslcontext.getSocketFactory());而且不报错,接口正常调用。
调用的接口是http,不是https。是否跟对方的测试接口没有升级到tls1.2协议有关。
TLSSocketConnectionFactory代码与下帖完全一致。
https://blog.csdn.net/g5zhu5896/article/details/80429686#commentBox有知道的大神指点一下。

解决方案 »

  1.   

    先使用tcp分析软件(抓包软件)看看协商过程
      

  2.   

    升级jdk吧,别折腾了。
    参考
    https://stackoverflow.com/questions/33517476/tls-1-2-java-1-6-bouncycastle摘要
    90% of the time this works fine! But there are some cases in which we get an annoying error: "Internal TLS error, this could be an attack" . It has been checked that there is no attack. That's a common error based on the treatment of internal BouncyCastle exceptions. I'm trying to find a common pattern to those remote host that fails with little luck.
      

  3.   


    系统不方便升级jdk啊,蛋疼
      

  4.   


    系统不方便升级jdk啊,蛋疼
    系统不方便升级jdk啊,蛋疼貌似jdk1.6.0_121-b09支持tls1.2
    参考
    https://www.oracle.com/technetwork/java/javase/overview-156328.html#R160_121
      

  5.   


    系统不方便升级jdk啊,蛋疼
    系统不方便升级jdk啊,蛋疼貌似jdk1.6.0_121-b09支持tls1.2
    参考
    https://www.oracle.com/technetwork/java/javase/overview-156328.html#R160_121
    感谢大神,但是官网好像没有下载地址啊,最高的才1.6.0_45