List of usage examples for org.apache.http.conn.ssl SSLSocketFactory ALLOW_ALL_HOSTNAME_VERIFIER
X509HostnameVerifier ALLOW_ALL_HOSTNAME_VERIFIER
To view the source code for org.apache.http.conn.ssl SSLSocketFactory ALLOW_ALL_HOSTNAME_VERIFIER.
Click Source Link
From source file:org.ow2.proactive.scheduler.rest.utils.HttpUtility.java
public static void setInsecureAccess(HttpClient client) throws KeyManagementException, UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException { SSLSocketFactory socketFactory = new SSLSocketFactory(new RelaxedTrustStrategy(), SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); Scheme https = new Scheme("https", 443, socketFactory); client.getConnectionManager().getSchemeRegistry().register(https); }
From source file:brooklyn.networking.cloudstack.HttpUtil.java
public static HttpClient createHttpClient(URI uri, Optional<Credentials> credentials) { final DefaultHttpClient httpClient = new DefaultHttpClient(); // TODO if supplier returns null, we may wish to defer initialization until url available? if (uri != null && "https".equalsIgnoreCase(uri.getScheme())) { try {/*from www . ja v a 2 s .c o m*/ int port = (uri.getPort() >= 0) ? uri.getPort() : 443; SSLSocketFactory socketFactory = new SSLSocketFactory(new TrustAllStrategy(), SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); Scheme sch = new Scheme("https", port, socketFactory); httpClient.getConnectionManager().getSchemeRegistry().register(sch); } catch (Exception e) { LOG.warn("Error in HTTP Feed of {}, setting trust for uri {}", uri); throw Exceptions.propagate(e); } } // Set credentials if (uri != null && credentials.isPresent()) { String hostname = uri.getHost(); int port = uri.getPort(); httpClient.getCredentialsProvider().setCredentials(new AuthScope(hostname, port), credentials.get()); } return httpClient; }
From source file:fi.iki.dezgeg.matkakorttiwidget.matkakortti.NonverifyingSSLSocketFactory.java
public static AbstractHttpClient createNonverifyingHttpClient() throws Exception { KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); trustStore.load(null, null);/*from w ww .j a va 2 s . c o m*/ SSLSocketFactory sf = new NonverifyingSSLSocketFactory(trustStore); sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); HttpParams params = new BasicHttpParams(); HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1); HttpProtocolParams.setContentCharset(params, HTTP.UTF_8); SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); registry.register(new Scheme("https", sf, 443)); ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry); return new DefaultHttpClient(ccm, params); }
From source file:gov.nist.appvet.tool.synchtest.util.SSLWrapper.java
@SuppressWarnings("deprecation") public static HttpClient wrapClient(HttpClient base) { SSLContext ctx = null;//from w ww . ja va 2s.c o m X509TrustManager tm = null; SSLSocketFactory ssf = null; SchemeRegistry sr = null; try { ctx = SSLContext.getInstance("TLSv1.2"); tm = new X509TrustManager() { @Override public void checkClientTrusted(X509Certificate[] xcs, String string) throws CertificateException { } @Override public void checkServerTrusted(X509Certificate[] xcs, String string) throws CertificateException { } @Override public X509Certificate[] getAcceptedIssuers() { return null; } }; ctx.init(null, new TrustManager[] { tm }, null); ssf = new SSLSocketFactory(ctx); ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); final ClientConnectionManager ccm = base.getConnectionManager(); sr = ccm.getSchemeRegistry(); sr.register(new Scheme("https", 443, ssf)); return new DefaultHttpClient(ccm, base.getParams()); } catch (final Exception e) { return null; } finally { sr = null; ssf = null; tm = null; ctx = null; } }
From source file:org.dasein.cloud.azure.AzureSSLSocketFactory.java
public AzureSSLSocketFactory(AzureX509 creds) throws InternalException, NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super("TLS", creds.getKeystore(), AzureX509.PASSWORD, null, null, null, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); }
From source file:com.gistandard.androidbase.http.extension.VolleyEx.java
/** * Creates a default instance of the worker pool and calls {@link RequestQueue#start()} on it. * * @param context A {@link Context} to use for creating the cache dir. * @param stack An {@link HttpStack} to use for the network, or null for default. * @return A started {@link RequestQueue} instance. *//* ww w . j a v a 2 s . c om*/ public static RequestQueue newRequestQueue(Context context, HttpStack stack) { File cacheDir = new File(context.getCacheDir(), DEFAULT_CACHE_DIR); String userAgent = "volley/0"; try { String packageName = context.getPackageName(); PackageInfo info = context.getPackageManager().getPackageInfo(packageName, 0); userAgent = packageName + "/" + info.versionCode; } catch (NameNotFoundException e) { } if (stack == null) { if (Build.VERSION.SDK_INT >= 9) { try { // allow all ssl connection HttpsURLConnection.setDefaultHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); stack = new HurlStack(null, new SSLSocketFactoryEx()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { // Prior to Gingerbread, HttpUrlConnection was unreliable. // See: http://android-developers.blogspot.com/2011/09/androids-http-clients.html stack = new HttpClientStack(AndroidHttpClient.newInstance(userAgent)); } } Network network = new BasicNetwork(stack); RequestQueue queue = new RequestQueue(new DiskBasedCache(cacheDir), network); queue.start(); return queue; }
From source file:org.dasein.cloud.util.X509SSLSocketFactory.java
public X509SSLSocketFactory(X509Store creds) throws InternalException, NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super("TLS", creds.getKeystore(), X509Store.PASSWORD, null, null, null, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); }
From source file:com.amalto.workbench.utils.SSLContextProvider.java
public static HostnameVerifier getHostnameVerifier() { boolean verify = store.getBoolean(PreferenceConstants.VERIFY_HOSTNAME); if (verify) { return SSLSocketFactory.STRICT_HOSTNAME_VERIFIER; } else {//w w w . ja v a 2s .co m return SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER; } }
From source file:org.openhab.habdroid.util.MyHttpClient.java
protected void clientSSLSetup(Context ctx) { if (PreferenceManager.getDefaultSharedPreferences(ctx).getBoolean(Constants.PREFERENCE_SSLHOST, false)) { clientBuilder.hostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); client = clientBuilder.build();/* ww w . jav a2 s .c o m*/ } }
From source file:gov.nist.appvet.servlet.shared.SSLWrapper.java
@SuppressWarnings("deprecation") public synchronized static HttpClient wrapClient(HttpClient base) { SSLContext ctx = null;/*www. java2 s. c o m*/ X509TrustManager tm = null; SSLSocketFactory ssf = null; SchemeRegistry sr = null; try { ctx = SSLContext.getInstance("TLSv1.2"); tm = new X509TrustManager() { @Override public void checkClientTrusted(X509Certificate[] xcs, String string) throws CertificateException { } @Override public void checkServerTrusted(X509Certificate[] xcs, String string) throws CertificateException { } @Override public X509Certificate[] getAcceptedIssuers() { return null; } }; ctx.init(null, new TrustManager[] { tm }, null); ssf = new SSLSocketFactory(ctx); ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); final ClientConnectionManager ccm = base.getConnectionManager(); sr = ccm.getSchemeRegistry(); sr.register(new Scheme("https", 443, ssf)); return new DefaultHttpClient(ccm, base.getParams()); } catch (final Exception e) { log.error(e.getMessage().toString()); return null; } finally { sr = null; ssf = null; tm = null; ctx = null; } }