mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-18 18:29:16 +00:00
Cache Auto Clean
This commit is contained in:
1 parent
a7f52365ca
commit
2f141bd565
9 files changed
+130
-10
No files matched your search
@@ -7,8 +7,16 @@ import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
@@ -141,4 +149,30 @@ public class HttpUtil0 {
|
||||
public static boolean isLocal(String url){
|
||||
return url==null? false : !url.startsWith("http");
|
||||
}
|
||||
|
||||
//From: http://blog.csdn.net/xiyushiyi/article/details/46685387
|
||||
public static void ignoreHttpsCertificate(){
|
||||
HostnameVerifier doNotVerify = new HostnameVerifier() {
|
||||
|
||||
public boolean verify(String hostname, SSLSession session) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return new X509Certificate[] {};
|
||||
}
|
||||
public void checkClientTrusted(X509Certificate[] chain, String authType){}
|
||||
public void checkServerTrusted(X509Certificate[] chain, String authType){}
|
||||
}};
|
||||
|
||||
try {
|
||||
SSLContext sc = SSLContext.getInstance("TLS");
|
||||
sc.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
|
||||
HttpsURLConnection.setDefaultHostnameVerifier(doNotVerify);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user