httpclient访问https

fengwind1 fengwind1 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
在自己的机器做了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访问百度读到的输出流是明文,又是为什么

...全文
评论 2
收藏 已收藏
分享
返回顶部
fengwind1
Java EE 67,535 成员 225,843 内容