Example usage for javax.net.ssl SSLContext init

List of usage examples for javax.net.ssl SSLContext init

Introduction

In this page you can find the example usage for javax.net.ssl SSLContext init.

Prototype

public final void init(KeyManager[] km, TrustManager[] tm, SecureRandom random) throws KeyManagementException 

Source Link

Document

Initializes this context.

Usage

From source file:org.mcxiaoke.commons.http.ssl.EasySSLSocketFactory.java

private static SSLContext createEasySSLContext() throws IOException {
    try {// ww  w . ja  va2s .  c o  m
        SSLContext context = SSLContext.getInstance("TLS");
        context.init(null, new TrustManager[] { new TrustAllManager() }, null);
        return context;
    } catch (Exception e) {
        throw new IOException(e.getMessage());
    }
}

From source file:com.foundstone.certinstaller.EasySSLSocketFactory.java

private static SSLContext createEasySSLContext(OnCertsRecievedListener listener) throws IOException {
    try {//from   w ww.j av  a2  s. c om
        SSLContext context = SSLContext.getInstance("TLS");
        context.init(null, new TrustManager[] { new EasyX509TrustManager(null, listener) }, null);
        return context;
    } catch (Exception e) {
        throw new IOException(e.getMessage());
    }
}

From source file:ru.musicplayer.androidclient.network.EasySSLSocketFactory.java

private static SSLContext createEasySSLContext() throws IOException {
    try {//from   w  w w.  jav a  2  s . c o  m
        SSLContext context = SSLContext.getInstance("TLS");
        context.init(null, new TrustManager[] { new EasyTrustManager(null) }, null);
        return context;
    } catch (Exception e) {
        throw new IOException(e.getMessage());
    }
}

From source file:com.utest.domain.service.util.TrustedSSLUtil.java

private static SSLContext createSSLContext() {
    try {//w  ww.  j a va  2  s.c o m
        final SSLContext context = SSLContext.getInstance("SSL");
        context.init(null, new TrustManager[] { trustAllCerts }, null);
        return context;
    } catch (final Exception e) {
        throw new HttpClientError(e.toString());
    }
}

From source file:com.github.opengarageapp.GarageService.java

/**
 * Trust every server - dont check for any certificate
 */// w  w w .j  a v a 2  s  . c  o m
private static void trustAllHosts() {
    // Create a trust manager that does not validate certificate chains
    TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
        public java.security.cert.X509Certificate[] getAcceptedIssuers() {
            return new java.security.cert.X509Certificate[] {};
        }

        public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
        }

        public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
        }
    } };

    // Install the all-trusting trust manager
    try {
        SSLContext sc = SSLContext.getInstance("TLS");
        sc.init(null, trustAllCerts, new java.security.SecureRandom());
        HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.isec.helperapp.EasySSLSocketFactory.java

private static SSLContext createEasySSLContext() throws IOException {
    Log.i(TAG, "createEasySSLContext");
    try {//ww w  . ja  va 2s . c o  m
        SSLContext context = SSLContext.getInstance("TLS");
        context.init(null, TrustAllTrustManager.getTrustManagers(), null);
        return context;
    } catch (Exception e) {
        throw new IOException(e.getMessage());
    }
}

From source file:org.fusioninventory.utils.EasySSLSocketFactory.java

private static SSLContext createEasySSLContext() throws IOException {
    FusionInventory.log(EasySSLSocketFactory.class, "Create Easy SSL Context", Log.ERROR);
    try {//from   w w  w  .java 2 s  .co  m
        SSLContext context = SSLContext.getInstance("TLS");
        context.init(null, new TrustManager[] { new EasyX509TrustManager(null) }, null);
        return context;
    } catch (Exception e) {
        throw new IOException(e.getMessage());
    }
}

From source file:org.andromda.android.net.EasySSLSocketFactory.java

private static SSLContext createEasySSLContext() throws IOException {
    try {/* w w  w.j  a va  2s . c om*/
        final SSLContext context = SSLContext.getInstance("TLS");
        context.init(null, new TrustManager[] { new TrivialTrustManager() }, null);
        return context;
    } catch (final Exception e) {
        throw new IOException(e.getMessage());
    }
}

From source file:com.cazoodle.crawl.DummySSLProtocolSocketFactory.java

private static SSLContext createEasySSLContext() {
    try {//from   w  ww  . ja  v  a2s .c  om
        SSLContext context = SSLContext.getInstance("SSL");
        context.init(null, new TrustManager[] { new DummyX509TrustManager(null) }, null);
        return context;
    } catch (Exception e) {
        if (LOG.isErrorEnabled()) {
            LOG.error(e.getMessage(), e);
        }
        throw new HttpClientError(e.toString());
    }
}

From source file:sit.web.client.HTTPTrustHelper.java

public static void init(String securityAlgorithm, KeyManager[] kms, TrustManager[] tms) {
    // Install the all-trusting trust manager
    try {/*  w w w .  j  a v a 2  s.com*/
        SSLContext sc = SSLContext.getInstance(securityAlgorithm);
        sc.init(kms, tms, new java.security.SecureRandom());
        HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
    } catch (Exception ex) {
        Logger.getLogger(HttpHelper.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
    }

    HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {

        @Override
        public boolean verify(String string, SSLSession ssls) {
            return true;
        }
    });
    HttpsURLConnection.setFollowRedirects(true);
}