httpclient访问https

J2EE 码拜 8年前 (2016-05-29) 1281次浏览
在本人的机器做了tomcat单向认证,然后用httpclient4.x访问
CloseableHttpClient client=HttpClientFactory.getCloseableHttpClient()
HttpGet get=new HttpGet(“https://localhost:8443/”)
//        HttpGet get=new HttpGet(“https://www.baidu.com”)
CloseableHttpResponse response=client.execute(get)
BufferedReader reader=new BufferedReader(new InputStreamReader(response.getEntity().getContent()))
String line=reader.readLine()
while(line!=null){
log.debug(line);
line=reader.readLine()
}
访问本人的tomcat报错,SunCertPathBuilderException occurred when processing request: [GET] /cloudolp.dc/test/https
unable to find valid certification path to requested target。报错也可以理解,原因是没有配置证书,但是为什么访问百度不会有问题?本人也没有为百度配置证书。而且https是加密的,但本人用https访问百度读到的输出流是明文,又是为什么
解决方案

20

是不是方位类型为get报错了

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明httpclient访问https
喜欢 (0)
[1034331897@qq.com]
分享 (0)