Java 类org.apache.http.conn.ssl.AllowAllHostnameVerifier 实例源码

项目:aet    文件:TrustedHttpRequestExecutor.java   
@Override
public ResponseObject executeGetRequest(String url, int timeoutInMs) throws IOException {
  final HttpGet request = new HttpGet(url);
  setHeaders(request);
  setCookies(request);

  try (CloseableHttpClient httpClient =
      HttpClients.custom()
          .setHostnameVerifier(new AllowAllHostnameVerifier())
          .setSslcontext(trustAllSslContext())
          .setDefaultRequestConfig(buildRequestConfig(timeoutInMs))
          .build();
      CloseableHttpResponse response = httpClient.execute(request)) {
    Header[] headersArray = response.getAllHeaders();
    Map<String, List<String>> tmpHeaders = new HashMap<>();
    for (Header header : headersArray) {
      tmpHeaders.put(header.getName(), Collections.singletonList(header.getValue()));
    }
    return new ResponseObject(tmpHeaders, IOUtils.toByteArray(response.getEntity().getContent()));
  } catch (Exception e) {
    throw new IOException(String.format("Failed to connect to %s - %s", url, e.getMessage()), e);
  }
}
项目:chaos-lemur    文件:StandardDirectorUtils.java   
private static RestTemplate createRestTemplate(String host, String username, String password, Set<ClientHttpRequestInterceptor> interceptors) throws GeneralSecurityException {
    CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
    credentialsProvider.setCredentials(new AuthScope(host, 25555),
        new UsernamePasswordCredentials(username, password));

    SSLContext sslContext = SSLContexts.custom()
        .loadTrustMaterial(null, new TrustSelfSignedStrategy())
        .useTLS()
        .build();

    SSLConnectionSocketFactory connectionFactory = new SSLConnectionSocketFactory(sslContext, new AllowAllHostnameVerifier());

    HttpClient httpClient = HttpClientBuilder.create()
        .disableRedirectHandling()
        .setDefaultCredentialsProvider(credentialsProvider)
        .setSSLSocketFactory(connectionFactory)
        .build();

    RestTemplate restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory(httpClient));
    restTemplate.getInterceptors().addAll(interceptors);

    return restTemplate;
}
项目:athena    文件:RestSBControllerImpl.java   
private CloseableHttpClient getApacheSslBypassClient() throws NoSuchAlgorithmException,
        KeyManagementException, KeyStoreException {
    return HttpClients.custom().
            setHostnameVerifier(new AllowAllHostnameVerifier()).
            setSslcontext(new SSLContextBuilder()
                                  .loadTrustMaterial(null, (arg0, arg1) -> true)
                                  .build()).build();
}
项目:JSSample    文件:HttpUtils.java   
public static SchemeRegistry getSchemeRegistry() {
    try {
        KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
        trustStore.load(null, null);
        SSLSocketFactory.getSocketFactory().setHostnameVerifier(new AllowAllHostnameVerifier());
        SSLSocketFactory sf = new SSLSocketFactory(trustStore);
        sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
        HttpParams params = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(params, 10000);
        HttpConnectionParams.setSoTimeout(params, 10000);
        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));
        return registry;
    } catch (Exception e) {
        return null;
    }
}
项目:documentum-rest-client-java    文件:AbstractRestTemplateClient.java   
public AbstractRestTemplateClient ignoreAuthenticateServer() {
    //backward compatible with android httpclient 4.3.x
    if(restTemplate.getRequestFactory() instanceof HttpComponentsClientHttpRequestFactory) {
        try {
            SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build();
            X509HostnameVerifier verifier = ignoreSslWarning ? new AllowAllHostnameVerifier() : new BrowserCompatHostnameVerifier();
            SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(sslContext, verifier);
            HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory).build();
            ((HttpComponentsClientHttpRequestFactory)restTemplate.getRequestFactory()).setHttpClient(httpClient);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else {
        Debug.error("the request factory " + restTemplate.getRequestFactory().getClass().getName() + " does not support ignoreAuthenticateServer");
    }
    return this;
}
项目:bosh-java-client    文件:SpringDirectorClientBuilder.java   
private ClientHttpRequestFactory createRequestFactory(String host, String username,
        String password) {
    CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
    credentialsProvider.setCredentials(new AuthScope(host, 25555),
            new UsernamePasswordCredentials(username, password));

    SSLContext sslContext = null;
    try {
        sslContext = SSLContexts.custom()
                .loadTrustMaterial(null, new TrustSelfSignedStrategy()).useTLS().build();
    } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) {
        throw new DirectorException("Unable to configure ClientHttpRequestFactory", e);
    }

    SSLConnectionSocketFactory connectionFactory = new SSLConnectionSocketFactory(sslContext,
            new AllowAllHostnameVerifier());

    // disabling redirect handling is critical for the way BOSH uses 302's
    HttpClient httpClient = HttpClientBuilder.create().disableRedirectHandling()
            .setDefaultCredentialsProvider(credentialsProvider)
            .setSSLSocketFactory(connectionFactory).build();

    return new HttpComponentsClientHttpRequestFactory(httpClient);
}
项目:search    文件:HttpClientUtilTest.java   
@Test
@SuppressWarnings("deprecation")
public void testSSLSystemProperties() {
  try {
    SSLTestConfig.setSSLSystemProperties();
    assertNotNull("HTTPS scheme could not be created using the javax.net.ssl.* system properties.", 
        HttpClientUtil.createClient(null).getConnectionManager().getSchemeRegistry().get("https"));

    System.clearProperty(HttpClientUtil.SYS_PROP_CHECK_PEER_NAME);
    assertEquals(BrowserCompatHostnameVerifier.class, getHostnameVerifier(HttpClientUtil.createClient(null)).getClass());

    System.setProperty(HttpClientUtil.SYS_PROP_CHECK_PEER_NAME, "true");
    assertEquals(BrowserCompatHostnameVerifier.class, getHostnameVerifier(HttpClientUtil.createClient(null)).getClass());

    System.setProperty(HttpClientUtil.SYS_PROP_CHECK_PEER_NAME, "");
    assertEquals(BrowserCompatHostnameVerifier.class, getHostnameVerifier(HttpClientUtil.createClient(null)).getClass());

    System.setProperty(HttpClientUtil.SYS_PROP_CHECK_PEER_NAME, "false");
    assertEquals(AllowAllHostnameVerifier.class, getHostnameVerifier(HttpClientUtil.createClient(null)).getClass());
  } finally {
    SSLTestConfig.clearSSLSystemProperties();
    System.clearProperty(HttpClientUtil.SYS_PROP_CHECK_PEER_NAME);
  }
}
项目:JSSE_Fortify_SCA_Rules    文件:ApacheHTTPClientFluentExample.java   
public void test1() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, ClientProtocolException, IOException{
    // ## SHOULD FIRE OVER-PERMISSIVE HOSTNAME VERIFIER
    CloseableHttpClient httpClient = HttpClients.custom().
            setHostnameVerifier(new AllowAllHostnameVerifier()).
            setSslcontext(new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {
                // ## SHOULD FIRE OVER-PERMISSIVE TRUST MANAGER
                @Override
                public boolean isTrusted(X509Certificate[] arg0, String arg1) throws java.security.cert.CertificateException {
                    return true;
                }
            }).build()).build();
    HttpGet httpget = new HttpGet("https://www.google.com/");
    CloseableHttpResponse response = httpClient.execute(httpget);
    try {
        System.out.println(response.toString());
    } finally {
        response.close();
    }
}
项目:hdfs-broker    文件:HgmHttpsConfiguration.java   
@Bean
@Qualifier("hgmRestTemplate")
public RestTemplate getHgmHttpsRestTemplate() throws KeyStoreException, NoSuchAlgorithmException,
    KeyManagementException {
  SSLContext sslContext =
      SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy()).useTLS()
          .build();
  SSLConnectionSocketFactory connectionFactory =
      new SSLConnectionSocketFactory(sslContext, new AllowAllHostnameVerifier());
  BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
  credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(configuration.getUsername(),
      configuration.getPassword()));

  HttpClient httpClient =
      HttpClientBuilder.create().setSSLSocketFactory(connectionFactory)
          .setDefaultCredentialsProvider(credentialsProvider).build();

  ClientHttpRequestFactory requestFactory =
      new HttpComponentsClientHttpRequestFactory(httpClient);
  return new RestTemplate(requestFactory);
}
项目:tinkerpop    文件:AbstractGremlinServerChannelizerIntegrateTest.java   
private CloseableHttpClient createSslHttpClient() throws Exception {
    final SSLContextBuilder wsBuilder = new SSLContextBuilder();
    wsBuilder.loadTrustMaterial(null, new TrustStrategy() {
        @Override
        public boolean isTrusted(X509Certificate[] chain,
            String authType) throws CertificateException {
            return true;
        }
    });
    final SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(wsBuilder.build(),
        new AllowAllHostnameVerifier());
    //This winds up using a PoolingHttpClientConnectionManager so need to pass the
    //RegistryBuilder
    final Registry<ConnectionSocketFactory> registry = RegistryBuilder
        .<ConnectionSocketFactory> create().register("https", sslsf)
        .build();
    final PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(registry);
    return HttpClients
        .custom()
        .setConnectionManager(cm)
        .build();

}
项目:Scale    文件:ScaleSession.java   
@PostConstruct
public void init() {
    try {
        HttpClientInfo httpci = this.commonConfig.createHttpClientInfo();

        http  = HttpClients.custom()
                .setConnectionManager(httpci.getCm()).setDefaultRequestConfig(httpci.getGlobalConfig()).setHostnameVerifier(new AllowAllHostnameVerifier())
                .build();


        URL uurl = new URL(commonConfig.getScaleConfig().getServiceConfiguration()
                .getUnisonURL());
        int port = uurl.getPort();

        HttpServletRequest request = (HttpServletRequest) FacesContext
                .getCurrentInstance().getExternalContext().getRequest();
        this.login = request.getRemoteUser();
    } catch (Exception e) {
        logger.error("Could not initialize ScaleSession",e);
    }

}
项目:androidclient    文件:ClientHTTPConnection.java   
@SuppressWarnings("deprecation")
@SuppressLint("AllowAllHostnameVerifier")
private void setupClient(HttpURLConnection conn, boolean acceptAnyCertificate)
        throws CertificateException, UnrecoverableKeyException,
        NoSuchAlgorithmException, KeyStoreException,
        KeyManagementException, NoSuchProviderException,
        IOException {

    // bug caused by Lighttpd
    //conn.setRequestProperty("Expect", "100-continue");
    conn.setConnectTimeout(CONNECT_TIMEOUT);
    conn.setReadTimeout(READ_TIMEOUT);
    conn.setDoInput(true);
    if (conn instanceof HttpsURLConnection) {
        ((HttpsURLConnection) conn).setSSLSocketFactory(setupSSLSocketFactory(mContext,
            mPrivateKey, mCertificate, acceptAnyCertificate));
        if (acceptAnyCertificate)
            ((HttpsURLConnection) conn).setHostnameVerifier(new AllowAllHostnameVerifier());
    }
}
项目:oxAuth    文件:HttpService.java   
public HttpClient getHttpsClientTrustAll() {
    try {
        SSLSocketFactory sf = new SSLSocketFactory(new TrustStrategy(){
            @Override
            public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
                return true;
            }
        }, new AllowAllHostnameVerifier());

        PlainSocketFactory psf = PlainSocketFactory.getSocketFactory();

        SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http", 80, psf));
        registry.register(new Scheme("https", 443, sf));
        ClientConnectionManager ccm = new PoolingClientConnectionManager(registry);
        return new DefaultHttpClient(ccm);
    } catch (Exception ex) {
        log.error("Failed to create TrustAll https client", ex);
        return new DefaultHttpClient();
    }
}
项目:metharto    文件:Conection.java   
public DefaultHttpClient BuildHttpClient() throws UnknownHostException, NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {

        SSLSocketFactory sf = new SSLSocketFactory(new TrustStrategy() {
            @Override
            public boolean isTrusted(X509Certificate[] chain,
                    String authType) throws CertificateException {
                return true;
            }
        }, new AllowAllHostnameVerifier());
        SchemeRegistry registry = new SchemeRegistry();
        registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        registry.register(new Scheme("https", sf, 443));

        ThreadSafeClientConnManager ccm = new ThreadSafeClientConnManager(registry);
        //ClientConnectionManager ccm=new SingleClientConnManager(registry);
        DefaultHttpClient httpclient = new DefaultHttpClient(ccm);
        ccm.setMaxTotal(999);
        ccm.setDefaultMaxPerRoute(10);

        return httpclient;
    }
项目:Supervisor    文件:JsonServiceCheck.java   
protected HttpClient createClient() throws Exception {
    DefaultHttpClient result = new DefaultHttpClient();
    SchemeRegistry sr = result.getConnectionManager().getSchemeRegistry();

    SSLSocketFactory sslsf = new SSLSocketFactory(new TrustStrategy() {

        @Override
        public boolean isTrusted(X509Certificate[] arg0, String arg1)
                throws CertificateException {
            return true;
        }
    }, new AllowAllHostnameVerifier());

    Scheme httpsScheme2 = new Scheme("https", 443, sslsf);
    sr.register(httpsScheme2);

    return result;
}
项目:seexian    文件:SeeXianNetUtils.java   
private static void initHttpClient() {
    final HttpParams params = new BasicHttpParams();
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setUseExpectContinue(params, true);
    HttpProtocolParams.setUserAgent(params, USER_AGENT);

    HttpConnectionParams.setConnectionTimeout(params, HTTP_TIMEOUT);
    HttpConnectionParams.setSoTimeout(params, HTTP_TIMEOUT);

    final SchemeRegistry registry = new SchemeRegistry();
    registry.register(new Scheme("http", PlainSocketFactory
            .getSocketFactory(), 80));
    SSLSocketFactory sslSocketFactory = SSLSocketFactory.getSocketFactory();
    sslSocketFactory.setHostnameVerifier(new AllowAllHostnameVerifier());
    registry.register(new Scheme("https", sslSocketFactory, 443));

    final ThreadSafeClientConnManager manager = new ThreadSafeClientConnManager(
            params, registry);

    sHttpClient = new DefaultHttpClient(manager, params);
}
项目:otus-api    文件:HttpClientFactory.java   
/**
 * Ignore any validation about certificate. Use of this feature has security
 * consequences
 *
 * @return
 * @throws RestCallException
 */
public static CloseableHttpClient createIgnoringCertificate() throws RestCallException {
    try {
        CloseableHttpClient httpClient = HttpClients.custom().setHostnameVerifier(new AllowAllHostnameVerifier())
                .setSslcontext(new SSLContextBuilder().loadTrustMaterial(null, (arg0, arg1) -> true).build()).build();

        return httpClient;
    } catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) {
        throw new RestCallException();
    }
}
项目:doc    文件:TransformerClient.java   
private static CloseableHttpClient getConfiguredHttpClient() {
    try {

        return HttpClients.custom()
                .setDefaultRequestConfig(RequestConfig.custom().setSocketTimeout(SOCKET_TIMEOUT)
                        .setConnectTimeout(CONNECTION_TIMEOUT).build())
                .setHostnameVerifier(new AllowAllHostnameVerifier())
                .setSslcontext(new SSLContextBuilder().loadTrustMaterial(null, (_1, _2) -> true).build()).build();
    } catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) {
        throw new RuntimeException(e);
    }
}
项目:ircradio    文件:TrustAllSSLSocketFactory.java   
public TrustAllSSLSocketFactory() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException {
    super(null);
        try {
            SSLContext sslcontext = SSLContext.getInstance("TLS");
            sslcontext.init(null, new TrustManager[] { new TrustAllManager() }, null);
            factory = sslcontext.getSocketFactory();
            setHostnameVerifier(new AllowAllHostnameVerifier());            
        } catch(Exception ex) { }
}
项目:pedefacil    文件:TrustAllSSLSocketFactory.java   
public TrustAllSSLSocketFactory() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException {
    super(null);
        try {
            SSLContext sslcontext = SSLContext.getInstance("TLS");
            sslcontext.init(null, new TrustManager[] { new TrustAllManager() }, null);
            factory = sslcontext.getSocketFactory();
            setHostnameVerifier(new AllowAllHostnameVerifier());
        } catch(Exception ex) { }
}
项目:Camel    文件:HttpsTwoDifferentSslContextParametersGetTest.java   
@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry registry = super.createRegistry();
    registry.bind("x509HostnameVerifier", new AllowAllHostnameVerifier());
    registry.bind("sslContextParameters", new SSLContextParameters());
    registry.bind("sslContextParameters2", new SSLContextParameters());

    return registry;
}
项目:Camel    文件:HttpsTwoComponentsSslContextParametersGetTest.java   
@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry registry = super.createRegistry();
    registry.bind("x509HostnameVerifier", new AllowAllHostnameVerifier());
    registry.bind("sslContextParameters", new SSLContextParameters());
    registry.bind("sslContextParameters2", new SSLContextParameters());

    registry.bind("http4s-foo", new HttpComponent());
    registry.bind("http4s-bar", new HttpComponent());

    return registry;
}
项目:Camel    文件:HttpsAuthenticationTest.java   
@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry registry = super.createRegistry();
    registry.bind("x509HostnameVerifier", new AllowAllHostnameVerifier());

    return registry;
}
项目:Camel    文件:HttpsGetTest.java   
@Override
protected JndiRegistry createRegistry() throws Exception {
    JndiRegistry registry = super.createRegistry();
    registry.bind("x509HostnameVerifier", new AllowAllHostnameVerifier());

    return registry;
}
项目:virgin-mobile-minutes-checker    文件:GsWebPageScraperClassic.java   
@Override
void getWebPageContents(String phoneNumber, String pin) throws MalformedURLException, IOException
{
    this.prepareConnection();
    String url = "https://www2.virginmobileusa.com/login/login.do" +
            "?min=" + phoneNumber +
            "&vkey=" + pin +
            "&submit=submit" +
            "&loginRoutingInfo=https://www2.virginmobileusa.com:443/myaccount/home.do";

    HttpsURLConnection connection = (HttpsURLConnection) new URL(url).openConnection();
    //connection.addRequestProperty("Cookie", "u_cst=3");
    connection.addRequestProperty("Accept-Language", "en-US,en;q=0.8");
    connection.addRequestProperty("Accept-Encoding", "gzip");
    //connection.addRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
       ((HttpsURLConnection) connection).setHostnameVerifier(new AllowAllHostnameVerifier());
       connection.setInstanceFollowRedirects(true);
       InputStream iStream = (InputStream) connection.getContent();
       GZIPInputStream inStream = new GZIPInputStream(iStream);
       InputStreamReader in = new InputStreamReader(inStream);

       BufferedReader buff = new BufferedReader(in);
       StringBuilder sb = new StringBuilder();      
    String line = "";
    //String lineSep = System.getProperty("line.separator");
    while ((line = buff.readLine()) != null)
    {
        sb.append(line);
        //sb.append(lineSep);
    }
    connection.disconnect();
    this.mainPageContents = sb.toString();
}
项目:fullstop    文件:HttpClientConfig.java   
@Bean
@Scope("prototype")
@SuppressWarnings("deprecation")
public CloseableHttpClient build() {
    final RequestConfig config = RequestConfig.custom()
            .setConnectionRequestTimeout(1000)
            .setConnectTimeout(1000)
            .setSocketTimeout(1000)
            .build();

    try {
        return HttpClientBuilder.create()
                .disableAuthCaching()
                .disableAutomaticRetries()
                .disableConnectionState()
                .disableCookieManagement()
                .disableRedirectHandling()
                .setDefaultRequestConfig(config)
                .setUserAgent("fullstop-job (https://github.com/zalando-stups/fullstop)")
                .setHostnameVerifier(new AllowAllHostnameVerifier())
                .setSslcontext(
                        new SSLContextBuilder()
                                .loadTrustMaterial(
                                        null,
                                        (arrayX509Certificate, value) -> true)
                                .build())
                .build();
    } catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) {
        throw new IllegalStateException("Could not initialize httpClient", e);
    }
}
项目:JSSE_Fortify_SCA_Rules    文件:ApacheHTTPClientFluentExample.java   
public void test2() throws ClientProtocolException, IOException{
    // ## SHOULD FIRE OVER-PERMISSIVE HOSTNAME VERIFIER
    CloseableHttpClient httpClient = HttpClients.custom().setHostnameVerifier(AllowAllHostnameVerifier.INSTANCE).build();
    HttpGet httpget = new HttpGet("https://www.google.com/");
    CloseableHttpResponse response = httpClient.execute(httpget);
    try {
        System.out.println(response.toString());
    } finally {
        response.close();
    }
}
项目:streamsx.topology    文件:AbstractStreamsConnection.java   
/**
 * Connection to IBM Streams
 * 
 * @param authorization
 *            String representing Authorization header used for connections.
 * @param allowInsecure
 *            Flag to allow insecure TLS/SSL connections. This is
 *            <strong>not</strong> recommended in a production environment
 * @param resourcesUrl
 *            String representing the root url to the REST API resources,
 *            for example: https://server:port/streams/rest/resources
 */
AbstractStreamsConnection(String authorization, String resourcesUrl,
        boolean allowInsecure) throws IOException {
    this.authorization = authorization;
    this.resourcesUrl = resourcesUrl;
    // Create the executor with a custom verifier if insecure connections
    // were requested
    try {
        if (allowInsecure) {
            // Insecure host connections were requested, try to set up
            CloseableHttpClient httpClient = HttpClients.custom()
                    .setHostnameVerifier(new AllowAllHostnameVerifier())
                    .setSslcontext(new SSLContextBuilder()
                            .loadTrustMaterial(null, new TrustStrategy() {
                                public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
                                    return true;
                                }
                            }).build()).build();
            executor = Executor.newInstance(httpClient);
            traceLog.info("Insecure Host Connection enabled");
        } else {
            // Default, secure host connections
            executor = Executor.newInstance();
        }
    } catch (NoSuchAlgorithmException | KeyStoreException | KeyManagementException e) {
        // Insecure was requested but could not be set up
        executor = Executor.newInstance();
        traceLog.info("Could not set up Insecure Host Connection");
    }
}
项目:Scale    文件:ScaleCommonConfig.java   
public HttpClientInfo createHttpClientInfo() {

    SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslctx,new AllowAllHostnameVerifier());
    PlainConnectionSocketFactory sf = PlainConnectionSocketFactory.getSocketFactory();
    Registry<ConnectionSocketFactory> r = RegistryBuilder.<ConnectionSocketFactory>create()
            .register("http", sf)
            .register("https", sslsf)
            .build();

    RequestConfig globalConfig = RequestConfig.custom().setCookieSpec(CookieSpecs.BROWSER_COMPATIBILITY).setRedirectsEnabled(true).build();

    PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(r);

    return new HttpClientInfo(cm,globalConfig);
}
项目:androidclient    文件:HTPPFileUploadConnection.java   
@SuppressLint("AllowAllHostnameVerifier")
@SuppressWarnings("deprecation")
private void setupClient(HttpsURLConnection conn, long length, String mime, boolean acceptAnyCertificate)
    throws CertificateException, UnrecoverableKeyException,
    NoSuchAlgorithmException, KeyStoreException,
    KeyManagementException, NoSuchProviderException,
    IOException {

    conn.setSSLSocketFactory(ClientHTTPConnection.setupSSLSocketFactory(mContext,
        null, null, acceptAnyCertificate));
    if (acceptAnyCertificate)
        conn.setHostnameVerifier(new AllowAllHostnameVerifier());
    conn.setRequestProperty("Content-Type", mime != null ? mime
        : "application/octet-stream");
    // bug caused by Lighttpd
    //conn.setRequestProperty("Expect", "100-continue");

    conn.setConnectTimeout(CONNECT_TIMEOUT);
    conn.setReadTimeout(READ_TIMEOUT);
    conn.setDoOutput(true);
    conn.setDoInput(true);
    conn.setRequestProperty("Content-Length", String.valueOf(length));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        conn.setFixedLengthStreamingMode(length);
    }
    else {
        conn.setFixedLengthStreamingMode((int) length);
    }
    conn.setRequestMethod("PUT");
}
项目:oxAuth    文件:BaseTest.java   
public static HttpClient createHttpClientTrustAll() throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
    SSLSocketFactory sf = new SSLSocketFactory(new TrustStrategy() {
        @Override
        public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
            return true;
        }
    }, new AllowAllHostnameVerifier());

    SchemeRegistry registry = new SchemeRegistry();
    registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
    registry.register(new Scheme("https", 443, sf));
    ClientConnectionManager ccm = new PoolingClientConnectionManager(registry);
    return new DefaultHttpClient(ccm);
}
项目:phimpme-android-v1    文件:TrustAllSSLSocketFactory.java   
public TrustAllSSLSocketFactory() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException {
    super(null);
    try {
        SSLContext sslcontext = SSLContext.getInstance("TLS");
        sslcontext.init(null, new TrustManager[]{new TrustAllManager()}, null);
        factory = sslcontext.getSocketFactory();
        setHostnameVerifier(new AllowAllHostnameVerifier());
    } catch (Exception ex) {
    }
}
项目:phimpme-android-v1    文件:TrustAllSSLSocketFactory.java   
public TrustAllSSLSocketFactory() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException { 
    super(null); 
        try { 
            SSLContext sslcontext = SSLContext.getInstance("TLS"); 
            sslcontext.init(null, new TrustManager[] { new TrustAllManager() }, null);
            factory = sslcontext.getSocketFactory();
            setHostnameVerifier(new AllowAllHostnameVerifier());             
        } catch(Exception ex) { } 
}
项目:onos    文件:HttpSBControllerImpl.java   
private CloseableHttpClient getApacheSslBypassClient() throws NoSuchAlgorithmException,
        KeyManagementException, KeyStoreException {
    return HttpClients.custom().
            setHostnameVerifier(new AllowAllHostnameVerifier()).
            setSslcontext(new SSLContextBuilder()
                                  .loadTrustMaterial(null, (arg0, arg1) -> true)
                                  .build()).build();
}
项目:moskito-central    文件:RESTHttpsConnector.java   
/**
 * During handshaking, if the URL's hostname and the server's identification hostname mismatch,
 * the verification mechanism can call back to this verifier to make a decision.
 *
 * @return {@link javax.net.ssl.HostnameVerifier} implementation instance according to connector's config.
 */
private HostnameVerifier getHostnameVerifier() {
    if (getConnectorConfig().isHostVerificationEnabled()) {
        return new BrowserCompatHostnameVerifier();
    }
    return new AllowAllHostnameVerifier();
}
项目:jester    文件:EstClientIT.java   
private HttpClient getNewHttpClient() throws Exception {
    SSLContextBuilder builder = new SSLContextBuilder();
    builder.loadTrustMaterial(null, new TrustSelfSignedStrategy());
    SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build(), new AllowAllHostnameVerifier());
    return HttpClients.custom().setSSLSocketFactory(sslsf).build();

}
项目:SinREST4Android    文件:MainTest.java   
public static void main(String[] args) {
        SSLSocketFactory.getSocketFactory().setHostnameVerifier(new AllowAllHostnameVerifier());


        // Create a WebResource
        WebResource resource = new WebResource("http://sinpy.sinaapp.com/rest/book/");
//      WebResource resource = new WebResource("http://127.0.0.1:9011/rest/book/");

        // Get all resource
        resource.get().accept(MediaType.APPLICATION_JSON).read();

        // Add a resource
        resource.post().accept(MediaType.APPLICATION_JSON).read("{\"name\": \"C Language\"}");

        // Get all resource
        resource.get().accept(MediaType.APPLICATION_JSON).read();

        // Modify resource witch id==1
        resource.put("1").accept(MediaType.APPLICATION_JSON).read("{\"name\": \"TCP/IP\"}");

        // Get all resource
        resource.get().accept(MediaType.APPLICATION_JSON).read();

        // Delete resource witch id==1
        resource.delete("1").accept(MediaType.APPLICATION_JSON).read();

        // Get all resource
        resource.get().accept(MediaType.APPLICATION_JSON).read();
    }
项目:YourAppIdea    文件:TrustAllSSLSocketFactory.java   
public TrustAllSSLSocketFactory() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException {
    super(null);
    try {
        SSLContext sslcontext = SSLContext.getInstance("TLS");
        sslcontext.init(null, new TrustManager[]{new TrustAllManager()}, null);
        factory = sslcontext.getSocketFactory();
        setHostnameVerifier(new AllowAllHostnameVerifier());
    } catch (Exception ex) {
    }
}
项目:photon-model    文件:VapiConnection.java   
public static HttpClient newUnsecureHttpClient() {
    return HttpClientBuilder.create()
            .setSslcontext(IgnoreSslErrors.newInsecureSslContext("TLS"))
            .setHostnameVerifier(new AllowAllHostnameVerifier())
            .build();
}
项目:photon-model    文件:VapiConnection.java   
private static HttpClient newDefaultHttpClient(TrustManager trustManager) {
    return HttpClientBuilder.create()
            .setSslcontext(IgnoreSslErrors.newTrustedSslContext("TLS", trustManager))
            .setHostnameVerifier(new AllowAllHostnameVerifier())
            .build();
}