解决jdk1.7不支持TSL1.2的有关问题(续)
解决jdk1.7不支持TSL1.2的问题(续)
解决jdk1.7 不支持TLS1.2的问题
续
windows环境打开jdk安装目录:jdk1.7.0_80\jre\bin,找到javacpl.exe
双击打开,高级选项卡,拉到最下方勾选TLS1.1 TLS1.2 ,如图
代码做微调: TLS 改为TLSv1.2
private static HttpClient httpClientEnableTLSTrust(final HttpClient base) { try { final SSLContext ctx = SSLContext.getInstance("TLSv1.2"); final TrustManager tm = new X509TrustManager() { @Override public void checkClientTrusted(final X509Certificate[] xcs, final String string) throws CertificateException { } @Override public void checkServerTrusted(final X509Certificate[] xcs, final String string) throws CertificateException { } @Override public X509Certificate[] getAcceptedIssuers() { return null; } }; ctx.init(null, new TrustManager[] { tm }, null); final SSLSocketFactory ssf = new SSLSocketFactory(ctx, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); final ClientConnectionManager ccm = base.getConnectionManager(); final SchemeRegistry sr = ccm.getSchemeRegistry(); sr.register(new Scheme("https", 443, ssf)); return new DefaultHttpClient(ccm, base.getParams()); } catch (final Exception ex) { ex.printStackTrace(); return null; } }
linux 环境
测试了两个版本,直接上图
其中checkTLS.jar 代码参考:查询JDK默认支持的SSL/TSL版本
就这