使用Jersey客户端的HTTPS
如何使用Jersey客户端API将GET请求发送到运行HTTPS协议的服务器。我可以使用任何示例代码吗?
回答:
这样构建您的客户
HostnameVerifier hostnameVerifier = HttpsURLConnection.getDefaultHostnameVerifier();ClientConfig config = new DefaultClientConfig();
SSLContext ctx = SSLContext.getInstance("SSL");
ctx.init(null, myTrustManager, null);
config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties(hostnameVerifier, ctx));
Client client = Client.create(config);
从此博客文章中窃取了更多详细信息:http
:
//blogs.oracle.com/enterprisetechtips/entry/consumption_restful_web_services_with
有关设置证书的信息,请参见以下已很好回答的SO问题:在Java中将HTTPS与REST一起使用
以上是 使用Jersey客户端的HTTPS 的全部内容, 来源链接: utcz.com/qa/416028.html