Package javax.net.ssl

Examples of javax.net.ssl.SSLContext


            // see http://docs.oracle.com/javase/6/docs/technotes/guides/security/jsse/JSSERefGuide.html#X509TrustManager
            tmf.init(keystore);
            managers = tmf.getTrustManagers();
          }

          SSLContext sslContext = SSLContext.getInstance("TLS");
          sslContext.init(null, managers, null);
          SSLEngine sslEngine = sslContext.createSSLEngine();
          sslEngine.setUseClientMode(true);
          List<String> enabledProtocols = new ArrayList<String>();
          for (String protocol : sslEngine.getEnabledProtocols()) {
            if (!excludeProtocols.contains(protocol)) {
              enabledProtocols.add(protocol);
View Full Code Here


        // Set up key manager factory to use our key store
        KeyManagerFactory kmf = KeyManagerFactory.getInstance(getAlgorithm());
        kmf.init(ks, keystorePassword.toCharArray());

        SSLContext serverContext = SSLContext.getInstance("TLS");
        serverContext.init(kmf.getKeyManagers(), null, null);
        return serverContext;
      } catch (Exception e) {
        throw new Error("Failed to initialize the server-side SSLContext", e);
      }
    }
View Full Code Here

    }

    @Override
    public SocketChannel newChannel(ChannelPipeline pipeline) {
      try {
        SSLContext sslContext = SSLContext.getInstance("TLS");
        sslContext.init(null, new TrustManager[]{new PermissiveTrustManager()},
                        null);
        SSLEngine sslEngine = sslContext.createSSLEngine();
        sslEngine.setUseClientMode(true);
        // addFirst() will make SSL handling the first stage of decoding
        // and the last stage of encoding
        pipeline.addFirst("ssl", new SslHandler(sslEngine));
        return super.newChannel(pipeline);
View Full Code Here

        // Set up key manager factory to use our key store
        KeyManagerFactory kmf = KeyManagerFactory.getInstance(getAlgorithm());
        kmf.init(ks, keystorePassword.toCharArray());

        SSLContext serverContext = SSLContext.getInstance("TLS");
        serverContext.init(kmf.getKeyManagers(), null, null);
        return serverContext;
      } catch (Exception e) {
        throw new Error("Failed to initialize the server-side SSLContext", e);
      }
    }
View Full Code Here

  private static HttpClient getHttpClient(String url, Integer connectionTimeout, Integer soTimeout) throws NoSuchAlgorithmException, KeyManagementException
  {
    Scheme httpsScheme = null;
    if (url.startsWith("https"))
    {
      SSLContext sslContext = SSLContext.getInstance("SSL");
      sslContext.init(null, new TrustManager[] { new X509TrustManager() {
              public X509Certificate[] getAcceptedIssuers()
              {
                return null;
              }
        public void checkClientTrusted(X509Certificate[] chain,  String authType) throws CertificateException
View Full Code Here

  private static HttpClient getHttpClient(String url, Integer connectionTimeout, Integer soTimeout) throws NoSuchAlgorithmException, KeyManagementException
  {
    Scheme httpsScheme = null;
    if (url.startsWith("https"))
    {
      SSLContext sslContext = SSLContext.getInstance("SSL");
      sslContext.init(null, new TrustManager[] { new X509TrustManager() {
              public X509Certificate[] getAcceptedIssuers()
              {
                return null;
              }
        public void checkClientTrusted(X509Certificate[] chain,  String authType) throws CertificateException
View Full Code Here

  private static HttpClient getHttpClient(String url, Integer connectionTimeout, Integer soTimeout) throws NoSuchAlgorithmException, KeyManagementException
  {
    Scheme httpsScheme = null;
    if (url.startsWith("https"))
    {
      SSLContext sslContext = SSLContext.getInstance("SSL");
      sslContext.init(null, new TrustManager[] { new X509TrustManager() {
              public X509Certificate[] getAcceptedIssuers()
              {
                return null;
              }
        public void checkClientTrusted(X509Certificate[] chain,  String authType) throws CertificateException
View Full Code Here

    return this.context;
  }

  private SSLContext build(Certificate key, Certificate trust) {
    try {
      SSLContext context = SSLContext.getInstance(this.protocol);
      context.init(this.getKeyManagers(key), this.getTrustManagers(trust), null);
      return context;
    } catch (Exception e) {
      this.log.fatal(e.toString());
      Trace.trace(this.log, e);
      return null;
View Full Code Here

  private static HttpClient getHttpClient(String url, Integer connectionTimeout, Integer soTimeout) throws NoSuchAlgorithmException, KeyManagementException
  {
    Scheme httpsScheme = null;
    if (url.startsWith("https"))
    {
      SSLContext sslContext = SSLContext.getInstance("SSL");
      sslContext.init(null, new TrustManager[] { new X509TrustManager() {
              public X509Certificate[] getAcceptedIssuers()
              {
                return null;
              }
        public void checkClientTrusted(X509Certificate[] chain,  String authType) throws CertificateException
View Full Code Here

    final TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(algorithm);
    trustManagerFactory.init(keyStore);

    // Initialize the SSLContext to work with our key managers.
    final SSLContext sslContext = SSLContext.getInstance(PROTOCOL);
    sslContext.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null);

    final SSLEngine sslEngine = sslContext.createSSLEngine();
    sslEngine.setUseClientMode(false);
    sslEngine.setWantClientAuth(true);

    return sslEngine;
  }
View Full Code Here

TOP

Related Classes of javax.net.ssl.SSLContext

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.