Package javax.net.ssl

Examples of javax.net.ssl.SSLContext


        return theSocket;
    }

    private SSLSocketFactory getSocketFactory() throws IOException {
        try {
            SSLContext sslCtx = SSLContext.getInstance("SSL");
            KeyManager[] aKM = SSLKeyManager.getKeyManagerArray();
            TrustManager[] aTM = SSLTrustManager.getTrustManagerArray();
            sslCtx.init(aKM, aTM, null);
            SSLSocketFactory socketFactory = sslCtx.getSocketFactory();
            return socketFactory;
        } catch (KeyManagementException e) {
            log.error("Cannot create SSL socket", e);
            throw new IOException("Cannot create SSL socket: " + e.getMessage());
        } catch (NoSuchAlgorithmException e) {
View Full Code Here


      kmf.init(ks, passphrase);
     
      TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
      tmf.init(ks);
 
      SSLContext sslContext = SSLContext.getInstance("TLS");
      sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);

      return sslContext;

    } catch (Exception e) {
      return null;
View Full Code Here

            for(int i=0;i<tm.getTrustManagers().length-1;i++) {
                tma[i] = tm.getTrustManagers()[i];
            }
            tma[tma.length-1] = trustManager;
        }
        SSLContext sslc = SSLContext.getInstance("SSL");
        sslc.init(kma, tma, SecureRandom.getInstance("SHA1PRNG"));
        SSLServerSocketFactory ssfc = sslc.getServerSocketFactory();
        if (log.isInfoEnabled())
          log.info("SSLServerSocketFactory=" + ssfc);
        initialised = true;
        return ssfc;
    }
View Full Code Here

      kmf.init(ks, passphrase);
     
      TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
      tmf.init(ks);
 
      SSLContext sslContext = SSLContext.getInstance("TLS");
      sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);

      return sslContext;

    } catch (Exception e) {
      return null;
View Full Code Here

            final KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
            kmf.init(ks,keyStorePwd.toCharArray());
           
            // initializing the ssl context
            if (this.log.isFine()) this.log.logFine("Initializing SSL context ...");
            final SSLContext sslcontext = SSLContext.getInstance("TLS");
            sslcontext.init(kmf.getKeyManagers(), null, null);
           
            final SSLSocketFactory factory = sslcontext.getSocketFactory();
            this.log.logInfo("SSL support initialized successfully");
            return factory;
        } catch (final Exception e) {
            final String errorMsg = "FATAL ERROR: Unable to initialize the SSL Socket factory. " + e.getMessage();
            this.log.logSevere(errorMsg);
View Full Code Here

 
  @Test
    public void testSSL() throws Exception {
     
     
      SSLContext sslContext = SSLTestContextFactory.getSSLContext();
     
        IServer server = new HttpServer(0, new ContentEchoHandler(), sslContext, true);
        server.start();

        INonBlockingConnection tcpCon = new NonBlockingConnection("localhost", server.getLocalPort(), sslContext, true);
View Full Code Here

 
  @Test
    public void testHttpClientSSL() throws Exception {
       
       
        SSLContext sslContext = SSLTestContextFactory.getSSLContext();
       
        IServer server = new HttpServer(0, new ContentEchoHandler(), sslContext, true);
        server.start();

       
View Full Code Here

                       
                        public void checkServerTrusted(final X509Certificate[] certs, final String authType) { /* NOP */ }
                      }
                    };
                                         
    SSLContext sslContext = SSLContext.getInstance("SSL");
    sslContext.init(null, trustAllCerts, null);
    return sslContext;
  }
View Full Code Here

                       
                        public void checkServerTrusted(final X509Certificate[] certs, final String authType) { /* NOP */ }
                      }
                    };
                                         
    SSLContext sslContext = SSLContext.getInstance("SSL");
    sslContext.init(null, trustAllCerts, null);
    return sslContext;
  }
View Full Code Here

 
  @Test
    public void testSSL() throws Exception {
     
     
      SSLContext sslContext = SSLTestContextFactory.getSSLContext();
     
        IServer server = new HttpServer(0, new ContentEchoHandler(), sslContext, true);
        server.start();

        INonBlockingConnection tcpCon = new NonBlockingConnection("localhost", server.getLocalPort(), sslContext, true);
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.