java.lang.Object
net.i2p.router.client.ClientListenerRunner
net.i2p.router.client.SSLClientListenerRunner
All Implemented Interfaces:
Runnable

class SSLClientListenerRunnerextends ClientListenerRunner
SSL version of ClientListenerRunner.
  • Field Details

  • Constructor Details

    • SSLClientListenerRunner

      public SSLClientListenerRunner(RouterContext context, ClientManager manager, int port)
      Creates an SSL listener on the given port, opening the client manager.
      Parameters:
      context - the router context
      manager - the client manager to attach to the listener
      port - the SSL port to listen on
  • Method Details

    • verifyKeyStore

      private boolean verifyKeyStore(File ks)
      Verify the keystore exists and is usable, creating it if necessary.
      Parameters:
      ks - the keystore file to verify
      Returns:
      success if it exists and we have a password, or it was created successfully.
    • createKeyStore

      private boolean createKeyStore(File ks)
      Call out to keytool to create a new keystore with a keypair in it. Trying to do this programatically is a nightmare, requiring either BouncyCastle libs or using proprietary Sun libs, and it's a huge mess. If successful, stores the keystore password and key password in router.config.
      Parameters:
      ks - the keystore file to create
      Returns:
      true if the keystore was created and its passwords saved
    • exportCert

      private void exportCert(File ks)
      Pull the cert back OUT of the keystore and save it as ascii so the clients can get to it.
      Parameters:
      ks - the keystore to export the certificate from
    • initializeFactory

      private boolean initializeFactory(File ks)
      The SSLContext and socket factory set up from the given keystore.
      Parameters:
      ks - the keystore to read the key material from
      Returns:
      true if the factory was built and stored, false if the keystore could not be read
    • getServerSocket

      protected ServerSocket getServerSocket() throws IOException
      A SSLServerSocket from the configured socket factory.
      Overrides:
      getServerSocket in class ClientListenerRunner
      Returns:
      the server socket
      Throws:
      IOException - if the socket cannot be created
    • runServer

      protected void runServer()
      Create (if necessary) and load the key store, then run.
      Overrides:
      runServer in class ClientListenerRunner
    • validate

      protected boolean validate(Socket socket)
      Overridden because SSL handshake may need more time, and available() in super doesn't work. The handshake doesn't start until a read().
      Overrides:
      validate in class ClientListenerRunner
      Parameters:
      socket - the accepted connection to probe for the I2CP protocol byte
      Returns:
      true if the first byte is the I2CP protocol byte