Package javax.net.ssl

Examples of javax.net.ssl.HttpsURLConnection$DefaultHostnameVerifier


      boolean chunked = "chunked".equals(request.getFirstHeaderOrNull("Transfer-Encoding"));
      URL url = request.getEndpoint().toURL();

      HttpURLConnection connection = (HttpURLConnection) url.openConnection(proxyForURI.apply(request.getEndpoint()));
      if (connection instanceof HttpsURLConnection) {
         HttpsURLConnection sslCon = (HttpsURLConnection) connection;
         if (utils.relaxHostname())
            sslCon.setHostnameVerifier(verifier);
         if (sslContextSupplier != null) {
             // used for providers which e.g. use certs for authentication (like FGCP)
             // Provider provides SSLContext impl (which inits context with key manager)
             sslCon.setSSLSocketFactory(sslContextSupplier.get().getSocketFactory());
         } else if (utils.trustAllCerts()) {
             sslCon.setSSLSocketFactory(untrustedSSLContextProvider.get().getSocketFactory());
         }
      }
      connection.setConnectTimeout(utils.getConnectionTimeout());
      connection.setReadTimeout(utils.getSocketOpenTimeout());
      connection.setAllowUserInteraction(false);
View Full Code Here


        CertificateFactory cf = CertificateFactory.getInstance("X.509");
        URL link = new URL(url);
        URLConnection connection = link.openConnection();
        InputStream is = null;
        if (connection instanceof HttpsURLConnection) {
            HttpsURLConnection hu = (HttpsURLConnection) link.openConnection();
            is = hu.getInputStream();
        } else {
            is = link.openStream();
        }
        X509Certificate x509Cert = (X509Certificate) cf.generateCertificate(is);
        return x509Cert;
View Full Code Here

        if(_lbHost == null || _lbPort==null) {
            String msg = _strMgr.getString("LbDeviceNotConfigured", _lbName);
            throw new IOException(msg);
        }
       
        HttpsURLConnection conn =null;
        URL url = null;
        try {
            //---------------------------------
            // Create a trust manager that does not validate certificate chains
            TrustManager[] trustAllCerts = new TrustManager[]{
                new X509TrustManager() {
                    public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                        return null;
                    }
                    public void checkClientTrusted(
                            java.security.cert.X509Certificate[] certs, String authType) {
                    }
                    public void checkServerTrusted(
                            java.security.cert.X509Certificate[] certs, String authType) {
                    }
                }
            };
           
            // Install the all-trusting trust manager
            SSLContext sc = SSLContext.getInstance(SSL);
            sc.init(SSLUtils.getKeyManagers(), trustAllCerts, new java.security.SecureRandom());
           
            //---------------------------------
            url = new URL(HTTPS_PROTOCOL,_lbHost,Integer.parseInt(_lbPort),contextRoot);
            if(_lbProxyHost!=null && _lbProxyPort !=null){
                Proxy proxy = new Proxy(Proxy.Type.HTTP,
                        new InetSocketAddress(_lbProxyHost, Integer.parseInt(_lbProxyPort)));
                conn = (HttpsURLConnection)url.openConnection(proxy);
            }else {
                conn = (HttpsURLConnection)url.openConnection();
            }
            conn.setSSLSocketFactory(sc.getSocketFactory());
            HostnameVerifier hnv = new SSLHostNameVerifier();
            conn.setDefaultHostnameVerifier(hnv);
        } catch(Exception e){
            if(_logger.isLoggable(Level.INFO))
                e.printStackTrace();
            throw new IOException(e.getMessage());
        }finally {
View Full Code Here

            System.clearProperty("jetty.ssl.password");
        }
        System.setProperty("javax.net.ssl.trustStore", "target/test-classes/tuscany.keyStore");
        System.setProperty("javax.net.ssl.trustStorePassword", "apache");
        URL url = new URL("https://127.0.0.1:8085/foo");
        HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
        conn.setHostnameVerifier(new HostnameVerifier() {
            public boolean verify(String hostname, SSLSession session) {
                return true;
            }}
        );

        conn.connect();
        read(conn.getInputStream());
       
        service.stop();
        assertTrue(servlet.invoked);

    }
View Full Code Here

      final URL url = new URL(constructUrlFromClientRequest());
      final HttpURLConnection connection = (HttpURLConnection) url.openConnection();

      if (HttpSchemes.HTTPS.equals(clientHttpRequest.getScheme())) {
         final HttpsURLConnection sslConnection = (HttpsURLConnection) connection;
         sslConnection.setHostnameVerifier(new DefaultHostnameVerifier());
      }

      connection.setRequestMethod(clientHttpRequest.getMethod());
      connection.setUseCaches(false);
      connection.setInstanceFollowRedirects(false);
View Full Code Here

        if (_lbHost == null || _lbPort == null) {
            String msg = LbLogUtil.getStringManager().getString("LbDeviceNotConfigured", _lbName);
            throw new IOException(msg);
        }

        HttpsURLConnection conn = null;
        URL url = null;
        try {
            //---------------------------------
            // Create a trust manager that does not validate certificate chains
            TrustManager[] trustAllCerts = new TrustManager[]{
                new X509TrustManager() {

                    @Override
                    public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                        return null;
                    }

                    @Override
                    public void checkClientTrusted(
                            java.security.cert.X509Certificate[] certs, String authType) {
                    }

                    @Override
                    public void checkServerTrusted(
                            java.security.cert.X509Certificate[] certs, String authType) {
                    }
                }
            };

            // Install the all-trusting trust manager
            SSLContext sc = SSLContext.getInstance(TLS);
            ServiceLocator habitat = Globals.getDefaultHabitat();
            SSLUtils sslUtils = habitat.getService(SSLUtils.class);
            sc.init(sslUtils.getKeyManagers(), trustAllCerts, new java.security.SecureRandom());

            //---------------------------------
            url = new URL(HTTPS_PROTOCOL, _lbHost, Integer.parseInt(_lbPort), contextRoot);
            if (_lbProxyHost != null && _lbProxyPort != null) {
                Proxy proxy = new Proxy(Proxy.Type.HTTP,
                        new InetSocketAddress(_lbProxyHost, Integer.parseInt(_lbProxyPort)));
                conn = (HttpsURLConnection) url.openConnection(proxy);
            } else {
                conn = (HttpsURLConnection) url.openConnection();
            }
            conn.setSSLSocketFactory(sc.getSocketFactory());
            HostnameVerifier hnv = new SSLHostNameVerifier();
            conn.setDefaultHostnameVerifier(hnv);
        } catch (Exception e) {
            throw new IOException(e.getMessage(), e);
        }
        return conn;
    }
View Full Code Here

        uc.setConnectTimeout(request.resolveProperty(ClientProperties.CONNECT_TIMEOUT, uc.getConnectTimeout()));

        uc.setReadTimeout(request.resolveProperty(ClientProperties.READ_TIMEOUT, uc.getReadTimeout()));

        if (uc instanceof HttpsURLConnection) {
            HttpsURLConnection suc = (HttpsURLConnection) uc;

            final JerseyClient client = request.getClient();
            final HostnameVerifier verifier = client.getHostnameVerifier();
            if (verifier != null) {
                suc.setHostnameVerifier(verifier);
            }
            suc.setSSLSocketFactory(client.getSslContext().getSocketFactory());
        }

        final Object entity = request.getEntity();
        if (entity != null) {
            RequestEntityProcessing entityProcessing = request.resolveProperty(
View Full Code Here

        }

        protected URLConnection openConnection(URL url) throws IOException {
            URLConnection con = url.openConnection();
            if ("HTTPS".equalsIgnoreCase(url.getProtocol())) {
                HttpsURLConnection scon = (HttpsURLConnection) con;
                try {
                    scon.setSSLSocketFactory(SSLUtil.getSSLSocketFactory(ks, password, alias));
                    scon.setHostnameVerifier(SSLUtil.getHostnameVerifier(SSLUtil.HOSTCERT_MIN_CHECK));
                } catch (GeneralException e) {
                    throw new IOException(e.getMessage());
                } catch (GeneralSecurityException e) {
                    throw new IOException(e.getMessage());
                }
View Full Code Here

            URLConnection con = null;
            try {
                con = url.openConnection();

                if ("HTTPS".equalsIgnoreCase(url.getProtocol())) {
                    HttpsURLConnection scon = (HttpsURLConnection) con;
                    try {
                        scon.setSSLSocketFactory(SSLUtil.getSSLSocketFactory(clientCertAlias, trustAnyCert));
                        HostnameVerifier hv = SSLUtil.getHostnameVerifier(hostCertLevel);
                        if (hv != null) {
                            scon.setHostnameVerifier(hv);
                        }
                    } catch (GeneralSecurityException e) {
                        Debug.logError(e, module);
                    } catch (GenericConfigException e) {
                        Debug.logError(e, module);
View Full Code Here

            throw new IOException("Illegal Protocol "
                    + url.getProtocol()
                    + " for HTTPS URLConnection Factory.");
        }
       
        HttpsURLConnection connection =
            (HttpsURLConnection) (proxy != null
                                   ? url.openConnection(proxy)
                                   : url.openConnection());
                                  
        if (tlsClientParameters != null) {
View Full Code Here

TOP

Related Classes of javax.net.ssl.HttpsURLConnection$DefaultHostnameVerifier

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.