Class SslPortTest

  • All Implemented Interfaces:
    java.util.EventListener, javax.net.ssl.HandshakeCompletedListener

    public class SslPortTest
    extends java.lang.Object
    implements javax.net.ssl.HandshakeCompletedListener
    Test the connection to a SSL server port and get the certificate chain.
    • Constructor Summary

      Constructors 
      Constructor Description
      SslPortTest​(java.lang.String host, int port)
      Create a new instance.
    • Constructor Detail

      • SslPortTest

        public SslPortTest​(java.lang.String host,
                           int port)
        Create a new instance.
        Parameters:
        host - the server host
        port - the server port
    • Method Detail

      • setTCPConnectTimeout

        public void setTCPConnectTimeout​(int tcpConnectTimeoutMillis)
        Set the TCP connect timeout.
        Parameters:
        tcpConnectTimeoutMillis - the TCP connect timeout in milliseconds
      • setSSLHandshakeTimeout

        public void setSSLHandshakeTimeout​(int sslHandshakeTimeoutMillis)
        Set the SSL handshake timeout.
        Parameters:
        sslHandshakeTimeoutMillis - the SSL handshake timeout in milliseconds
      • setClientAuthKeyManagers

        public void setClientAuthKeyManagers​(javax.net.ssl.KeyManager[] clientAuthKeyManagers)
        Set SSL key managers for client authentication.
        Parameters:
        clientAuthKeyManagers - the key managers for SSL client authentication
      • setLocalOutboundAddress

        public void setLocalOutboundAddress​(java.lang.String localOutboundAddress)
                                     throws java.net.UnknownHostException
        Set the local outbound address.
        Parameters:
        localOutboundAddress - the local outbound address
        Throws:
        java.net.UnknownHostException - if the local outbound address is invalid
      • testConnection

        public boolean testConnection()
        Test the TCP connection.
        Returns:
        true if the TCP connection was established and then closed, or false if connecting to the server has failed.
      • getConnectLog

        public java.util.ArrayList<java.lang.String> getConnectLog()
        Get the connect log.
        Returns:
        the connect log
      • getTcpConnectTime

        public long getTcpConnectTime()
        Get the TCP connect time in milliseconds.
        Returns:
        the TCP connect time in milliseconds, or -1 if no such information is available
      • getSslHandshakeTime

        public long getSslHandshakeTime()
        Get the SSL handshake time in milliseconds.
        Returns:
        the SSL handshake time in milliseconds, or -1 if no such information is available
      • getPeerCertificateChain

        public java.util.List<java.security.cert.X509Certificate> getPeerCertificateChain()
        Get the chain of the received SSL server certificates.
        Returns:
        a list of the received SSL server certificates
      • getCertificateChainArray

        public JsonArray getCertificateChainArray()
                                           throws java.lang.Exception
        Get a JSON array of the received SSL server certificates.
        Returns:
        the JSON array of the received SSL server certificates
        Throws:
        java.lang.Exception - if somewhat fails
      • handshakeCompleted

        public void handshakeCompleted​(javax.net.ssl.HandshakeCompletedEvent handshakeCompletedEvent)
        Implementation of HandshakeCompletedListener interface.
        Specified by:
        handshakeCompleted in interface javax.net.ssl.HandshakeCompletedListener
        Parameters:
        handshakeCompletedEvent - the event identifying when the SSL Handshake completed on a given SSL connection