官方主頁:http://hc.apache.org/
Components
Custom SSL context
This example demonstrates how to create secure connections with a custom SSL context.
自定义SSL内容
这个例子示范怎样用自定义SSL内容创建一个安全的连接。
package cn.lake.util;
import java.io.File;
import java.io.FileInputStream;
import java.security.KeyStore;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.impl.client.DefaultHttpClient;
/**
* This example demonstrates how to create secure connections with a custom SSL
* context.
*/
public class ClientCustomSSL {
public final static void main(String[] args) throws Exception {
DefaultHttpClient httpclient = new DefaultHttpClient();
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
FileInputStream instream = new FileInputStream(new File("my.keystore"));
try {
trustStore.load(instream, "nopassword".toCharArray());
} finally {
instream.close();
}
SSLSocketFactory socketFactory = new SSLSocketFactory(trustStore);
Scheme sch = new Scheme("https", socketFactory, 443);
httpclient.getConnectionManager().getSchemeRegistry().register(sch);
HttpGet httpget = new HttpGet("https://localhost/");
System.out.println("executing request" + httpget.getRequestLine());
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
if (entity != null) {
System.out.println("Response content length: " + entity.getContentLength());
}
if (entity != null) {
entity.consumeContent();
}
}
}
翻譯的不好,請見諒!
分享到:
- 2009-01-15 13:58
- 浏览 2002
- 评论(3)
- 论坛回复 / 浏览 (3 / 4693)
- 查看更多
相关推荐
http远程接口调用-httpClient+跳过SSL证书校验. 里面分别有3个httpClient的工具类代码。 还有一个专门为了跳过SSL证书校验的工具类。
这是一个关于httpclient4.5访问https网站的例子,可以绕过ssl认证直接访问
JAVAHttpClientThe server failed to respond with a validCaused by: org.apache.htt
使用HttpClient4.5实现https请求忽略SSL证书验证工具类
Maven坐标:org.apache.httpcomponents:httpclient:4.5.13; 标签:apache、httpcomponents、httpclient、jar包、java、中文文档; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档...
AndroidHttpClient访问Tomcat双向SSL验证服务器.pdf
以上自己测试是可行的,直接拿过去导入即可,直接用main
import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.methods....
赠送jar包:httpclient-4.5.5.jar; 赠送原API文档:httpclient-4.5.5-javadoc.jar; 赠送源代码:httpclient-4.5.5-sources.jar; 包含翻译后的API文档:httpclient-4.5.5-javadoc-API文档-中文(简体)版.zip ...
java SSL HttpClient。java 通过ssl去访问服务器(tomcat)
只是jar包
SSLContext Kickstart :locked_with_key: 使用以下方法安装库: 用安装 < groupId>io.github.hakky54 < artifactId>sslcontext-kickstart < version>6.2.0 使用Gradle安装 implementation ' io.github.hakky54:...
ribbon-httpclient-2.2.5.jar
wechatpay-apache-httpclient 概览 的扩展,实现了请求签名的生成和应答签名的验证。...implementation 'com.github.wechatpay-apiv3:wechatpay-apache-httpclient:0.2.2' Maven 加入以下依赖 <groupId>com.github.w
下面给大家展示了AndroidHttpClient结构: public final class AndroidHttpClient extends Object implements HttpClient 前言: 这类其实是Google对阿帕奇的HttpClient的一个封装,一些默认属性有android做了一些...
NULL 博文链接:https://chnwaterloo.iteye.com/blog/690549
HttpClient配置SSL绕过https证书实例,附件中包含所需httpclient组件jar库。博客地址:http://blog.csdn.net/irokay/article/details/78801307。
Maven坐标:org.apache.httpcomponents:httpclient:4.5.6; 标签:apache、httpcomponents、httpclient、jar包、java、中文文档; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档...
Maven坐标:org.apache.httpcomponents:httpclient:4.5.13; 标签:apache、httpcomponents、httpclient、jar包、java、中英对照文档; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览...
基于c++11 httpclient https://github.com/iEternity/HttpClient github上是基于win的,附件为linux平台,以及android源码环境生成的主机host bin程序,在android 8.1,linux14.04环境均编译通过 内含CMakelists ...