【发布时间】:2017-07-28 22:43:05
【问题描述】:
问题:我想通过 jersey 客户端使用 HTTPS Restful Webservice。
1) 我从第 3 方获得 CARoot 证书并安装在浏览器 (Mozilla) 上,我可以从 Mozilla 浏览器上的 RestClient 访问这些服务。
i) RootCA.pem ii) SubCA-Client.pem iii) abc_sdsdllkl_p12.pfx
2) 我想使用 jersey 客户端在 JAVA 代码中配置这个 Web 服务。
3) 在 java 代码中配置这些证书的步骤是什么。
4) 我不想在本地 JRE 中配置这些。
PAttributes pd = new PAttributes();
ClassLoader classLoader = pd.getClass().getClassLoader();
File file = new File(classLoader.getResource("cacerts").getFile());
System.setProperty("javax.net.ssl.trustStore",file.getAbsolutePath());
System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
Client client = Client.create();
WebResource webResource = client.resource("https://xyz/abc/getAttributes");
String input = new PAttributes().getRequestBody();
ClientResponse clientResponse = webResource.accept("application/xml").type("application/xml").post(ClientResponse.class, input);
String output = clientResponse.getEntity(String.class);
System.out.println("output"+output);
我已经从浏览器下载了.crt文件,需要配置,不知道怎么配置?
【问题讨论】:
标签: java web-services rest