码迷,mamicode.com
首页 > 编程语言 > 详细

java https客户端请求

时间:2017-05-14 18:08:05      阅读:284      评论:0      收藏:0      [点我收藏+]

标签:new t   custom   resource   ons   java   copyto   string   blog   copy   

String pathname = Test3.class.getResource("/client.jks").getFile();
System.out.println(pathname);
SSLContext sslContext = SSLContexts.custom()
				.loadTrustMaterial(new File(pathname), "123456".toCharArray(),
						new TrustSelfSignedStrategy())
				.build();
HttpGet request = new HttpGet("https://91ihealth.com:8443/");
HttpClient client = HttpClientBuilder.create()
				.setSslcontext(sslContext).build();
HttpResponse response = client.execute(request);
System.out.println(StreamUtils.copyToString(response.getEntity().getContent(), Charset.defaultCharset()));

  

java https客户端请求

标签:new t   custom   resource   ons   java   copyto   string   blog   copy   

原文地址:http://www.cnblogs.com/kingsy/p/6852874.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!