|
|
@@ -1,33 +0,0 @@
|
|
|
-package com.wj.exception;
|
|
|
-
|
|
|
-import javax.net.ssl.HttpsURLConnection;
|
|
|
-import javax.net.ssl.SSLContext;
|
|
|
-import javax.net.ssl.TrustManager;
|
|
|
-import javax.net.ssl.X509TrustManager;
|
|
|
-import java.security.cert.X509Certificate;
|
|
|
-
|
|
|
-public class SSLUtil {
|
|
|
- public static void ignoreSSLVerification() throws CustomXmlParseException {
|
|
|
- try {
|
|
|
- TrustManager[] trustAllCertificates = new TrustManager[]{
|
|
|
- new X509TrustManager() {
|
|
|
- public X509Certificate[] getAcceptedIssuers() {
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- public void checkClientTrusted(X509Certificate[] certs, String authType) {
|
|
|
- }
|
|
|
-
|
|
|
- public void checkServerTrusted(X509Certificate[] certs, String authType) {
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- SSLContext sslContext = SSLContext.getInstance("TLS");
|
|
|
- sslContext.init(null, trustAllCertificates, new java.security.SecureRandom());
|
|
|
- HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
|
|
|
- } catch (Exception e) {
|
|
|
- throw new CustomXmlParseException(e);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|