-
-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
muxiannian
committed
Nov 4, 2019
1 parent
5185cf9
commit aa2f8e6
Showing
10 changed files
with
134 additions
and
23 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...oupdatelibrary/net/OkHttp3Connection.java → ...pdateproject/utils/OkHttp3Connection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...utoupdatelibrary/src/main/java/com/cretin/www/cretinautoupdatelibrary/utils/SSLUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.cretin.www.cretinautoupdatelibrary.utils; | ||
|
||
import android.annotation.SuppressLint; | ||
|
||
import java.security.SecureRandom; | ||
import java.security.cert.CertificateException; | ||
import java.security.cert.X509Certificate; | ||
|
||
import javax.net.ssl.HostnameVerifier; | ||
import javax.net.ssl.SSLContext; | ||
import javax.net.ssl.SSLSession; | ||
import javax.net.ssl.SSLSocketFactory; | ||
import javax.net.ssl.TrustManager; | ||
import javax.net.ssl.X509TrustManager; | ||
|
||
/** | ||
* @date: on 2019-11-04 | ||
* @author: a112233 | ||
* @email: [email protected] | ||
* @desc: 添加描述 | ||
*/ | ||
public class SSLUtils { | ||
@SuppressLint("TrulyRandom") | ||
public static SSLSocketFactory createSSLSocketFactory() { | ||
SSLSocketFactory sSLSocketFactory = null; | ||
try { | ||
SSLContext sc = SSLContext.getInstance("TLS"); | ||
sc.init(null, new TrustManager[]{new TrustAllManager()}, | ||
new SecureRandom()); | ||
sSLSocketFactory = sc.getSocketFactory(); | ||
} catch (Exception ignored) { | ||
} | ||
return sSLSocketFactory; | ||
} | ||
|
||
public static class TrustAllManager implements X509TrustManager { | ||
@SuppressLint("TrustAllX509TrustManager") | ||
@Override | ||
public void checkClientTrusted(X509Certificate[] chain, String authType) | ||
throws CertificateException { | ||
} | ||
|
||
@SuppressLint("TrustAllX509TrustManager") | ||
@Override | ||
public void checkServerTrusted(X509Certificate[] chain, String authType) | ||
throws CertificateException { | ||
} | ||
|
||
@Override | ||
public X509Certificate[] getAcceptedIssuers() { | ||
return new X509Certificate[0]; | ||
} | ||
} | ||
|
||
public static class TrustAllHostnameVerifier implements HostnameVerifier { | ||
@SuppressLint("BadHostnameVerifier") | ||
@Override | ||
public boolean verify(String hostname, SSLSession session) { | ||
return true; | ||
} | ||
} | ||
} |