在Java 1.4中使用TLSV1.2时没有此类算法异常 [英] Getting No such algorithm exception while using TLSV1.2 in java 1.4

查看:265
本文介绍了在Java 1.4中使用TLSV1.2时没有此类算法异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试访问支持TLSv1.2的Web服务。我正在使用Java 1.4。它不支持TLSv1.2。



现在有人告诉我,卑诗省可以解决我的问题。
虽然它可以与SSLEngine一起工作,但是以某种方式替换掉了吗?
卑诗省有可能吗?



要获得可用的 SSLEngine (与
中的TLSv1一起使用),我该怎么办?无阻塞io方案)对DH的基本大小没有如此低的限制。



我尝试了什么:

  Security.addProvider(new BouncyCastleProvider()); 

仅此一项似乎并不能解决问题。



所以不是

  SSLContext .getInstance( TLSv1); //只能正常工作的小DH键。 

我尝试致电以下内容:



<学前班= lang-java prettyprint-override> SSLContext.getInstance( TLSv1, BC);

SSLContext.getInstance( TLS, BC);

SSLContext.getInstance( TLSv1.2, BC);

SSLContext.getInstance( ssl, BC);

尽管它们都抛出 NoSuchAlgorithmException

解决方案

我可以使用 bctls lib来解决此问题,但不幸的是,它似乎没有 Java 1.4 的版本。



我可以在 Bouncy Castle的网站 Mvn存储库 bctls-jdk15on-157 (对于 Java> = 1.5 )。



无论如何,如果升级为您的Java版本是可能的,您只需要将此jar添加到您的项目中,并使用 org.bouncycastle.jsse.provider.BouncyCastleJsseProvider 类(我已使用 Java 1.7 (此测试)):

  //添加JSSE提供程序
Security.addProvider(new BouncyCastleJsseProvider());

//测试
SSLContext.getInstance( TLSv1.1,BouncyCastleJsseProvider.PROVIDER_NAME);
SSLContext.getInstance( TLSv1.2,BouncyCastleJsseProvider.PROVIDER_NAME);
SSLContext.getInstance( TLSv1,BouncyCastleJsseProvider.PROVIDER_NAME);

以上所有测试均无错误。



检查所有受支持的SSL协议:

  SSLContext context = SSLContext.getInstance( TLSv1, BouncyCastleJsseProvider.PROVIDER_NAME); 
System.out.println(Arrays.toString(context.getSupportedSSLParameters()。getProtocols())); // [TLSv1.1,TLSv1,TLSv1.2]

输出为:


[TLSv1.1,TLSv1,TLSv1.2]



I am trying to hit a webservice which supports TLSv1.2. I am using Java 1.4. It does not support TLSv1.2.

Now someone told me that BC could solve my problem. Though does it work with a SSLEngine as drop in replacement somehow? Is this possible with BC?

What do I have to do to get a working SSLEngine (for use with TLSv1 in a nonblocking io scenario) without such low restrictions on primesize for DH.

What I tried:

Security.addProvider(new BouncyCastleProvider()); 

This alone seems not to solve the problem.

So instead of

SSLContext.getInstance("TLSv1");  //which works alas only little DH keys. 

I tried calling the following:

SSLContext.getInstance("TLSv1","BC"); 

SSLContext.getInstance("TLS","BC");

SSLContext.getInstance("TLSv1.2","BC");  

SSLContext.getInstance("ssl","BC"); 

Though all of them throws NoSuchAlgorithmException.

解决方案

I could solve this by using bctls lib, but unfortunatelly it doesn't seem to have a version for Java 1.4.

The only version that I could find in Bouncy Castle's website and in Mvn Repository is bctls-jdk15on-157 (for Java >= 1.5).

Anyway, if an upgrade of your Java version is possible, you just need to add this jar to your project and use the org.bouncycastle.jsse.provider.BouncyCastleJsseProvider class (I've used Java 1.7 for this test):

// add the JSSE provider
Security.addProvider(new BouncyCastleJsseProvider());

// tests
SSLContext.getInstance("TLSv1.1", BouncyCastleJsseProvider.PROVIDER_NAME);
SSLContext.getInstance("TLSv1.2", BouncyCastleJsseProvider.PROVIDER_NAME);
SSLContext.getInstance("TLSv1", BouncyCastleJsseProvider.PROVIDER_NAME);

All tests above run without error.

Checking all the SSL protocols supported:

SSLContext context = SSLContext.getInstance("TLSv1", BouncyCastleJsseProvider.PROVIDER_NAME);
System.out.println(Arrays.toString(context.getSupportedSSLParameters().getProtocols())); // [TLSv1.1, TLSv1, TLSv1.2]

The output is:

[TLSv1.1, TLSv1, TLSv1.2]

这篇关于在Java 1.4中使用TLSV1.2时没有此类算法异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆