瀏覽代碼

添加双向认证流程

Pq 1 年之前
父節點
當前提交
329510fa00

+ 4 - 0
BaseLibrary/src/main/java/com/cooleshow/base/data/auth/HttpsUtil.java

@@ -30,6 +30,10 @@ public class HttpsUtil {
         public X509TrustManager trustManager;
     }
 
+    public static X509TrustManager getTrustManager() {
+        return new UnSafeTrustManager();
+    }
+
     public static SSLParams getSslSocketFactory(InputStream[] certificates, InputStream bksFile, String password) {
         SSLParams sslParams = new SSLParams();
         try {

+ 1 - 1
BaseLibrary/src/main/java/com/cooleshow/base/data/net/RetrofitClientNoToken.java

@@ -40,7 +40,7 @@ public class RetrofitClientNoToken {
                 .connectTimeout(60, TimeUnit.SECONDS)
                 .readTimeout(60, TimeUnit.SECONDS)
                 .retryOnConnectionFailure(true)//错误重连
-                .sslSocketFactory(Https.getSSLCertifcation(Utils.getApp()))
+                .sslSocketFactory(Https.getSSLCertifcation(Utils.getApp()),HttpsUtil.getTrustManager())
                 .hostnameVerifier(new HttpsUtil.UnSafeHostnameVerifier())
                 .addInterceptor(initLogInterceptor())
                 .build();

+ 1 - 1
BaseLibrary/src/main/java/com/cooleshow/base/data/net/RetrofitClientUpFile.java

@@ -41,7 +41,7 @@ public class RetrofitClientUpFile {
 //                .cookieJar(cookieJar)
                 .cache(createMCache())
                 .retryOnConnectionFailure(true)//错误重连
-                .sslSocketFactory(Https.getSSLCertifcation(Utils.getApp()))
+                .sslSocketFactory(Https.getSSLCertifcation(Utils.getApp()),HttpsUtil.getTrustManager())
                 .hostnameVerifier(new HttpsUtil.UnSafeHostnameVerifier())
                 .addInterceptor(new CommonInterceptor())
                 .build();

+ 1 - 1
BaseLibrary/src/main/java/com/cooleshow/base/data/net/RetrofitFactory.kt

@@ -59,7 +59,7 @@ class RetrofitFactory private constructor() {
         return OkHttpClient.Builder()
             .addInterceptor(initLogInterceptor())
             .addInterceptor(CommonInterceptor())
-            .sslSocketFactory(Https.getSSLCertifcation(Utils.getApp()))
+            .sslSocketFactory(Https.getSSLCertifcation(Utils.getApp()),HttpsUtil.getTrustManager())
             .hostnameVerifier(HttpsUtil.UnSafeHostnameVerifier())
             .connectTimeout(20, TimeUnit.SECONDS)
             .readTimeout(20, TimeUnit.SECONDS)