Commit 0f4802cd by 郑娜伟

net 发布1.1.3 版本 okhttp 信任所有证书

parent 40da7eff
......@@ -21,12 +21,12 @@ dependencies {
// api 'com.sobot.library:utils:1.1.1'
// api 'com.sobot.library:picture:1.1.4'
// api 'com.sobot.library:net:1.1.2'
// api 'com.sobot.library:net:1.1.3'
// api 'com.sobot.library:gson:1.1.1'
// api 'com.sobot.library:utils:1.1.1'
// api 'com.sobot.library:picture_x:1.1.4'
// api 'com.sobot.library:net:1.1.2'
// api 'com.sobot.library:net:1.1.3'
// api 'com.sobot.library:gson:1.1.1'
}
......
......@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) {
ext {
PUBLISH_GROUP_ID = "com.sobot.library" //项目包名
PUBLISH_ARTIFACT_ID = 'net' //项目名
PUBLISH_VERSION = '1.1.2' //版本号
PUBLISH_VERSION = '1.1.3' //版本号
}
......
......@@ -20,6 +20,7 @@ import com.sobot.network.http.request.RequestCall;
import java.io.IOException;
import java.security.KeyStore;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
......@@ -296,7 +297,7 @@ public class SobotOkHttpUtils {
try {
SSLContext sc = SSLContext.getInstance("TLS");
sc.init(null, new TrustManager[]{manager},
sc.init(null, getTrustManager(),
new SecureRandom());
sSLSocketFactory = sc.getSocketFactory();
} catch (Exception e) {
......@@ -305,4 +306,26 @@ public class SobotOkHttpUtils {
return sSLSocketFactory;
}
//获取TrustManager
private static TrustManager[] getTrustManager() {
TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) {
}
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) {
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[]{};
}
}
};
return trustAllCerts;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment