You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					49 lines
				
				1.5 KiB
			
		
		
			
		
	
	
					49 lines
				
				1.5 KiB
			| 
											3 years ago
										 | //package com.ynxbd.common.config.http;
 | ||
|  | //
 | ||
|  | //
 | ||
|  | //import org.apache.http.conn.ssl.SSLSocketFactory;
 | ||
|  | //
 | ||
|  | //import javax.net.ssl.SSLContext;
 | ||
|  | //import javax.net.ssl.TrustManager;
 | ||
|  | //import java.security.KeyManagementException;
 | ||
|  | //import java.security.NoSuchAlgorithmException;
 | ||
|  | //
 | ||
|  | //public class MySSLSocketFactory extends SSLSocketFactory {
 | ||
|  | //
 | ||
|  | //    static {
 | ||
|  | //        mySSLSocketFactory = new MySSLSocketFactory(createSContext());
 | ||
|  | //    }
 | ||
|  | //
 | ||
|  | //    private static MySSLSocketFactory mySSLSocketFactory = null;
 | ||
|  | //
 | ||
|  | //
 | ||
|  | //    private static SSLContext createSContext() {
 | ||
|  | //        SSLContext sslcontext = null;
 | ||
|  | //        try {
 | ||
|  | //            sslcontext = SSLContext.getInstance("SSL");
 | ||
|  | //        } catch (NoSuchAlgorithmException e) {
 | ||
|  | //            e.printStackTrace();
 | ||
|  | //        }
 | ||
|  | //        try {
 | ||
|  | //            sslcontext.init(null, new TrustManager[]{new TrustAnyTrustManager()}, null);
 | ||
|  | //        } catch (KeyManagementException e) {
 | ||
|  | //            e.printStackTrace();
 | ||
|  | //            return null;
 | ||
|  | //        }
 | ||
|  | //        return sslcontext;
 | ||
|  | //    }
 | ||
|  | //
 | ||
|  | //    private MySSLSocketFactory(SSLContext sslContext) {
 | ||
|  | //        super(sslContext);
 | ||
|  | //        this.setHostnameVerifier(ALLOW_ALL_HOSTNAME_VERIFIER);
 | ||
|  | //    }
 | ||
|  | //
 | ||
|  | //    public static MySSLSocketFactory getInstance() {
 | ||
|  | //        if (mySSLSocketFactory != null) {
 | ||
|  | //            return mySSLSocketFactory;
 | ||
|  | //        } else {
 | ||
|  | //            return mySSLSocketFactory = new MySSLSocketFactory(createSContext());
 | ||
|  | //        }
 | ||
|  | //    }
 | ||
|  | //}
 |