我希望使用Spring应用程序调用一个REST服务。为了访问该服务,我有一个客户端证书(自签名且格式为.jks)用于授权。
如何正确地对REST服务进行身份验证?
这是我的请求:
public List<Info> getInfo() throws RestClientException, URISyntaxException {
HttpEntity<?> httpEntity = new HttpEntity<>(null, new HttpHeaders());
ResponseEntity<Info[]> resp = restOperations.exchange(
new URI(BASE_URL + "/Info"), HttpMethod.GET,
httpEntity, Info[].class);
return Arrays.asList(resp.getBody());
}
RestTemplate
对象上调用setRequestFactory
方法,而无需使用RestTemplateBuilder
。 - ChocolateAndCheese.jks
文件。我从GoDaddy下载了客户端证书,有两个文件是.crt
和.pem
。我尝试使用这些文件运行代码,但它抛出异常java.io.IOException: Invalid keystore format
。请指导。谢谢。 - Ankur Raiyani