java.security.NoSuchAlgorithmException:否这样的算法:提供者BCJSSE的TLS1.2

时间:2019-01-16 10:27:17

标签: java bouncycastle tls1.2

我正在使用充气城堡罐来获取TLS1.2实例,但出现以下异常: >

java.security.NoSuchAlgorithmException: no such algorithm: TLS1.2 for provider BCJSSE
at sun.security.jca.GetInstance.getService(GetInstance.java:157)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:281)
at javax.net.ssl.SSLContext.getInstance(SSLContext.java:24)
at com.fca.mopar.partSegmentation.service.PartDataService.getRestTemplate(PartDataService.java:108)
at com.fca.mopar.partSegmentation.service.PartDataService.fetchPartInfo(PartDataService.java:161)
at com.fca.mopar.partSegmentation.controllers.MPIMController.partDetails(MPIMController.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:599)

下面是代码:

`

Security.addProvider(new BouncyCastleJsseProvider());
SSLContext context = SSLContext.getInstance("TLS1.2", Security.getProvider("BCJSSE"));
context.init(null, null, null);
CloseableHttpClient httpClient = HttpClientBuilder.create().setSSLContext(context).build();
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient);
restTemplate = new RestTemplate(factory);

`

我们需要调用具有TLSv1.2的Web服务,并且我们的服务器具有较低的TLS版本,因此握手失败。 (JDK:v1.6,JARS:bcprov-jdk15on-160,bctls-jdk15on-160)。 如果我做错了什么,请有人帮我或举个例子。

0 个答案:

没有答案