【发布时间】:2018-02-01 11:43:32
【问题描述】:
在访问 HTTPS 服务时,我遇到了以下问题:
错误:
..Certification authentication failed</TITLE>
...
An attempt to authenticate with a client certificate failed.
A valid client certificate is required to make this connection.
我正在使用 Spring RestTemplate excahnge API:
restTemplate.exchange(reqInfo.getUrl(),HttpMethod.GET,requestEntity,String.class);
我尝试了 2 种方法来提供 trustStore,但错误仍然存在:
1.) 作为参数传递:
java -cp -Djavax.net.ssl.trustStore="trustStore.jks"
-Djavax.net.ssl.trustStorePassword="pwd" Test
2.) 设置属性
System.setProperty("javax.net.ssl.trustStore","path to truststore");
System.setProperty("javax.net.ssl.trustStorePassword","pwd");
我还尝试了使用 HTTPclient 的简单 Java 代码,然后它工作正常,但使用 SPring RestTemplate 没有一个选项工作,我在这里遗漏了什么吗?
注意:如果我对该 URL 进行卷曲,则会收到与未提供 truststore 相同的错误。因此,我假设这个问题是由于 TrustStore 造成的。
【问题讨论】:
标签: spring ssl https resttemplate truststore