Https VS Http 性能比拼
作者:网络转载 发布时间:[ 2012/10/9 13:08:10 ] 推荐标签:
因此在使用https 请求数据的时候要注意看看你的项目里面是否真的需要! 我在此给你一段 使用Android访问https 的代码:
private X509TrustManager xtm = new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] chain, String authType) {
}
public void checkServerTrusted(X509Certificate[] chain, String authType) {
// System.out.println("cert: " + chain[0].toString() + ", authType: "
// + authType);
}
public X509Certificate[] getAcceptedIssuers() {
return null;
}
};
private HostnameVerifier hnv = new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
//读取证书
return true;
}
};
private HttpsUtils() {
SSLContext sslContext = null;
try {
sslContext = SSLContext.getInstance("TLS");
X509TrustManager[] xtmArray = new X509TrustManager[] { xtm };
sslContext.init(null, xtmArray, new java.security.SecureRandom());
} catch (GeneralSecurityException gse) {
}
if (sslContext != null) {
HttpsURLConnection.setDefaultSSLSocketFactory(sslContext
.getSocketFactory());
}
HttpsURLConnection.setDefaultHostnameVerifier(hnv);
}
private static HttpsUtils instance = null;
public static HttpsUtils getInstance(){
if (instance == null) {
instance = new HttpsUtils();
}
return instance;
}
复制代码
按理来说,基本所以的智能手机都是支持的!我不太确定哈,如果不放心的话 使用Testin 简单测测吧!
相关推荐
更新发布
功能测试和接口测试的区别
2023/3/23 14:23:39如何写好测试用例文档
2023/3/22 16:17:39常用的选择回归测试的方式有哪些?
2022/6/14 16:14:27测试流程中需要重点把关几个过程?
2021/10/18 15:37:44性能测试的七种方法
2021/9/17 15:19:29全链路压测优化思路
2021/9/14 15:42:25性能测试流程浅谈
2021/5/28 17:25:47常见的APP性能测试指标
2021/5/8 17:01:11