webservice绕过https证书认证方法Word下载.docx

上传人:wj 文档编号:283929 上传时间:2023-04-28 格式:DOCX 页数:2 大小:12.56KB
下载 相关 举报
webservice绕过https证书认证方法Word下载.docx_第1页
第1页 / 共2页
webservice绕过https证书认证方法Word下载.docx_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

webservice绕过https证书认证方法Word下载.docx

《webservice绕过https证书认证方法Word下载.docx》由会员分享,可在线阅读,更多相关《webservice绕过https证书认证方法Word下载.docx(2页珍藏版)》请在冰点文库上搜索。

webservice绕过https证书认证方法Word下载.docx

trustAllHttpsCertificates();

HttpsURLConnection.setDefaultHostnameVerifier(hv);

将这两个方法放到开始连接url的前面就可以。

具体实现如下面:

直接复制就可以

/**

*跳过https访问webserivce的方法 start

*/

HostnameVerifierhv=newHostnameVerifier(){

publicbooleanverify(StringurlHostName,SSLSessionsession){

System.out.println("

Warning:

URLHost:

"

+urlHostName+"

vs."

+session.getPeerHost());

returntrue;

}

};

privatestaticvoidtrustAllHttpsCertificates()throwsException{

trustAllCerts=new

tm=newmiTM();

trustAllCerts[0]=tm;

sc=

.getInstance("

SSL"

);

sc.init(null,trustAllCerts,null);

setDefaultSSLSocketFactory(sc

.getSocketFactory());

}

staticclassmiTMimplements

{

publicgetAcceptedIssuers(){

returnnull;

publicbooleanisServerTrusted(

certs){

publicbooleanisClientTrusted(

publicvoidcheckServerTrusted(

certs,StringauthType)

throws{

return;

publicvoidcheckClientTrusted(

*跳过https访问webserivce的方法 end

视图

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > IT计算机 > 电脑基础知识

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2