OKGo https配置
/** * 第一种加载证书 */ try { HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory(getAssets().open("wallet.cer")); OkHttpClient builder = new OkHttpClient.Builder() .sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager) .hostnameVerifier(new HostnameVerifier() { @Override public boolean verify(String hostname, SSLSession session) { return true; } }).build(); OkGo.getInstance().setOkHttpClient(builder); }catch (Exception e){ e.printStackTrace(); }
/** * 第二种忽略证书 */ HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory(); OkHttpClient builder = new OkHttpClient.Builder() .sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager) .hostnameVerifier(new HostnameVerifier() { @Override public boolean verify(String hostname, SSLSession session) { return true; } }).build(); OkGo.getInstance().init(this).setOkHttpClient(builder);
----淡定从容,宁静致远----