Trust anchor for certification path not found.问题解决(关于okhttputils的BUG)
2017-09-26 11:21
483 查看
憋了3天,参照https://github.com/DeadLine837/TestHttps上的例子,与我的代码的区别,终于搞明白了 自签名,单向认证。 下面这两种写法就会报错: 1、============================== InputStream inputStream = getResources().getAssets().open("zhy_server.cer"); HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory(new InputStream[]{inputStream}, null, null); 2、============================== InputStream ins[] = null; ins[0] = getAssets().open("assets/zhy_server.cer"); HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory(ins, null, null); 下面这两种写法正确: 3、============================== HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory(new InputStream[]{new Buffer().writeUtf8(CER_12306).inputStream()}, null, null); 4、============================== HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory(new InputStream[]{getResources().getAssets().open("zhy_server.cer")}, null, null); 用别人的东西,踩着坑也没办法,放到网上给大家参照一下吧,节省点时间
相关文章推荐
- https 证书校验异常 Trust anchor for certification path not found
- android 屏蔽证书验证 CertPathValidatorException: Trust anchor for certification path not found
- Smack报错:Trust anchor for certification path not found
- Https报错java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
- Smack报错:Trust anchor for certification path not found
- JSP页面顶端出现错误:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path的问题解决
- 关于问题ld:library not found for -lXXX 和ld:warning:directory not found option 以及duplicate symbol的解决办法
- 访问Storm ui界面,出现org.apache.storm.utils.NimbusLeaderNotFoundException: Could not find leader nimbus from seed hosts ["master" "slave1"]. Did you specify a valid list of nimbus hosts for confi的问题解决(图文详解)
- andorid HTTPS 不需要证书 VolleyEror: com.android.volley.NoConnectionError: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not fou
- 【HTML5入门】解决The superclass javax.servlet.http.HttpServlet was not found on the Java Build Path问题
- retrofit2中ssl的Trust anchor for certification path not found问题
- retrofit2中ssl的Trust anchor for certification path not found问题,屏蔽https验证
- 解决"The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path"问题
- 关于问题ld:library not found for -lXXX 和ld:warning:directory not found option 以及duplicate symbol的解决办法
- 关于问题ld:library not found for -lXXX 和ld:warning:directory not found option 以及duplicate symbol的解决办法
- retrofit2中ssl的Trust anchor for certification path not found问题
- 访问Storm ui界面,出现org.apache.storm.utils.NimbusLeaderNotFoundException: Could not find leader nimbus from seed hosts ["master"]. Did you specify a valid list of nimbus hosts for confi的问题解决(图文详解)
- 关于wamp下http://localhost地址The requested URL / was not found on this server.问题解决过程分享
- 打包JAR错误 Class files on classpath not found or not accessible for 问题的解决
- 关于Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/ core"问题解决