com.android.org.bouncycastle.jce.exception.ExtCertPathValidatorException,OkHttp时间戳校验问题
Posted linwen5723
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了com.android.org.bouncycastle.jce.exception.ExtCertPathValidatorException,OkHttp时间戳校验问题相关的知识,希望对你有一定的参考价值。
这个问题不常见,但是我遇到了,网上不好搜,基本是onFailure:javax.net.ssl.SSLHandshakeException,所以我标题没有前面加上这个
原因:你看下你设备上系统时间是不是不对←..←
解决:
1、时间改过来啊
2、联网校验手机本地时间
public class SSLCertificate public static SSLSocketFactory SSLSocketFactorygetSSLSocketFactory() final TrustManager[] trustAllCerts =new TrustManager[] new X509TrustManager() @Override public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException @Override public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException @Override public X509Certificate[] getAcceptedIssuers() return new X509Certificate[0]; ; SSLContext sslContext =null; try sslContext = SSLContext.getInstance("SSL"); sslContext.init(null, trustAllCerts, new java.security.SecureRandom()); catch (NoSuchAlgorithmException e) e.printStackTrace(); catch (KeyManagementException e) e.printStackTrace(); final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory(); return sslSocketFactory;
对 OkHttpClient 时间校验
OkHttpClient.Builder builder = new OkHttpClient.Builder() .sslSocketFactory(SSLCertificate.SSLSocketFactorygetSSLSocketFactory()) .hostnameVerifier(new HostnameVerifier() @Override public boolean verify(String s, SSLSession sslSession) return true; );
OK,你试试吧
以上是关于com.android.org.bouncycastle.jce.exception.ExtCertPathValidatorException,OkHttp时间戳校验问题的主要内容,如果未能解决你的问题,请参考以下文章