Examples of SSLSocket


Examples of javax.net.ssl.SSLSocket

        }
    }
   
    public Socket negotiateSSL(final Socket sock) throws Exception {

        SSLSocket sslsock;
       
        try {
            sslsock=(SSLSocket)this.sslSocketFactory.createSocket(
                    sock,
                    sock.getInetAddress().getHostAddress(),
                    sock.getPort(),
                    true);

            sslsock.addHandshakeCompletedListener(
                    new HandshakeCompletedListener() {
                       public void handshakeCompleted(
                          final HandshakeCompletedEvent event) {
                          System.out.println("Handshake finished!");
                          System.out.println(
                          "\t CipherSuite:" + event.getCipherSuite());
                          System.out.println(
                          "\t SessionId " + event.getSession());
                          System.out.println(
                          "\t PeerHost " + event.getSession().getPeerHost());
                       }
                    }
                 );            
           
            sslsock.setUseClientMode(false);
            final String[] suites = sslsock.getSupportedCipherSuites();
            sslsock.setEnabledCipherSuites(suites);
//            start handshake
            sslsock.startHandshake();
           
            //String cipherSuite = sslsock.getSession().getCipherSuite();
           
            return sslsock;
        } catch (final Exception e) {
View Full Code Here

Examples of javax.net.ssl.SSLSocket

    }

// ----------------------------- subclass overrides ----------------------------
    public void configureSocket(Socket socket) {

        SSLSocket s;

        super.configureSocket(socket);

        s = (SSLSocket) socket;

        s.addHandshakeCompletedListener(this);
    }
View Full Code Here

Examples of javax.net.ssl.SSLSocket

     * @param port the server port
     * @throws Exception if a network or security provider error occurs
     */
    public Socket createSocket(String host, int port) throws Exception {

        SSLSocket socket;

        socket = (SSLSocket) getSocketFactoryImpl().createSocket(host, port);

        socket.addHandshakeCompletedListener(this);
        socket.startHandshake();

// unsaved@users
// For https protocol, the protocol handler should do this verification
// (Sun's implementation does), but if we do not use the Protocol
// handler (which is only available in Java >= 1.4), then we need to do
// the verification: hostname == cert CN
//
// boucherb@users 20030503:
// CHEKME/TODO:
//
// Stricter verify?  Either require SunJSSE (assume its trust manager properly
// verifies whole chain), or implement our own TrustManager layer?
//
// What about v1/v3 and signing checks (re: man-in-the-middle attack),
// CRL check, basic constraints? notBefore? notAfter?
//
// Reference:  http://www.securitytracker.com/alerts/2002/Aug/1005030.html
//
// That is, we can't guarantee that installed/prefered provider trust manager
// implementations verify the whole chain properly and there are still
// v1 certs out there (i.e. have no basic constraints, etc.), meaning that
// we should check for and reject any intermediate certs that are not v3+
// (cannot be checked for basic constraints).  Only root and intermediate
// certs found in the trust store should be allowed to be v1 (since we must
// be trusing them for them to be there).  All other intermediate signers,
// however, should be required to be v3+, otherwise anybody with any kind
// of cert issued somehow via a trust chain from the root can pose as an
// intermediate signing CA and hence leave things open to man-in-the-middle
// style attack.  Also, we should really check CRLs, just in case
// it turns out that trust chain has been breached and thus issuer has revoked
// on some cert(s).  Of course, this really begs the question, as it is not
// guaranteed that all CAs in trust store have valid, working CRL URL
//
// So what to do?
//
// Maybe best to leave this all up to DBA?
        verify(host, socket.getSession());

        return socket;
    }
View Full Code Here

Examples of javax.net.ssl.SSLSocket

    public void handshakeCompleted(HandshakeCompletedEvent evt) {

        SSLSession session;
        String     sessionId;
        SSLSocket  socket;

        if (Error.TRACE) {
            socket  = evt.getSocket();
            session = evt.getSession();
View Full Code Here

Examples of javax.net.ssl.SSLSocket

  }

  @Override
  protected Socket createSocket() throws IOException {
    SSLSocketFactory factory = HttpsURLConnection.getDefaultSSLSocketFactory();
    SSLSocket sslSocket = (SSLSocket) factory.createSocket();
    sslSocket.addHandshakeCompletedListener(new HandshakeCompletedListener() {
          @Override
          public void handshakeCompleted(HandshakeCompletedEvent event) {
            ThreadLocalMetricsRecorder.getInstance().getSslTimer().stop();
          }
        });
View Full Code Here

Examples of javax.net.ssl.SSLSocket

      Socket tunnel = new Socket(proxyHost, proxyPort);

      doTunnelHandshake(tunnel, host, port);

      SSLSocket sslSocket = (SSLSocket) sslFactory.createSocket(tunnel, host, port, autoClose);

      sslSocket.addHandshakeCompletedListener(new HandshakeCompletedListener() {
        public void handshakeCompleted(HandshakeCompletedEvent event) {
          // Handshake finished!"
          done = true;
        }
      });
      if (!done)
        sslSocket.startHandshake();

      return sslSocket;

    }
    else {
View Full Code Here

Examples of javax.net.ssl.SSLSocket

     */
    public Socket createSocket(String host, int port,
                               InetAddress clientHost, int clientPort)
        throws IOException, UnknownHostException {
        SSLSocketFactory sf = (SSLSocketFactory) SSLSocketFactory.getDefault();
        SSLSocket sslSocket = (SSLSocket) sf.createSocket(host, port,
                                                          clientHost,
                                                          clientPort);
        verifyHostname(sslSocket);

        return sslSocket;
View Full Code Here

Examples of javax.net.ssl.SSLSocket

     * @see SecureProtocolSocketFactory#createSocket(java.lang.String,int)
     */
    public Socket createSocket(String host, int port)
        throws IOException, UnknownHostException {
        SSLSocketFactory sf = (SSLSocketFactory) SSLSocketFactory.getDefault();
        SSLSocket sslSocket = (SSLSocket) sf.createSocket(host, port);
        verifyHostname(sslSocket);

        return sslSocket;
    }
View Full Code Here

Examples of javax.net.ssl.SSLSocket

     */
    public Socket createSocket(Socket socket, String host, int port,
                               boolean autoClose)
        throws IOException, UnknownHostException {
        SSLSocketFactory sf = (SSLSocketFactory) SSLSocketFactory.getDefault();
        SSLSocket sslSocket = (SSLSocket) sf.createSocket(socket, host,
                                                          port, autoClose);
        verifyHostname(sslSocket);

        return sslSocket;
    }
View Full Code Here

Examples of javax.net.ssl.SSLSocket

  @Override
  public void process(SipMessage message)
  {       
        TlsConnection tlsConnection = (TlsConnection) message.getConnection();
        SSLSocket sslSocket = tlsConnection.getSocket();
       
        try
        {
            SSLSession sslSession = sslSocket.getSession();
            X509Certificate[] certs = (X509Certificate[]) sslSession.getValue(X509Certificate.class.getName());
            if (certs == null)
            {
                certs = getCertChain(sslSession);
                if (certs == null)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.