java.lang.Object
net.i2p.i2ptunnel.SSLClientUtil

public class SSLClientUtilextends Object
SSL server socket utilities for I2PTunnel clients.
  • Field Details

  • Constructor Details

    • SSLClientUtil

      public SSLClientUtil()
      verifyKeyStore(Properties) and the socket factories below are static, and the only fields are property-name constants, so an instance carries nothing.
  • Method Details

    • verifyKeyStore

      public static boolean verifyKeyStore(Properties opts) throws IOException
      Create a new selfsigned cert and keystore and pubkey cert if they don't exist. May take a while.
      Parameters:
      opts - in/out, updated if rv is true
      Returns:
      false if it already exists; if true, caller must save opts
      Throws:
      IOException - on creation fail
    • verifyKeyStore

      public static boolean verifyKeyStore(Properties opts, String optPfx) throws IOException
      Create a new selfsigned cert and keystore and pubkey cert if they don't exist. May take a while.
      Parameters:
      opts - in/out, updated if rv is true
      optPfx - add this prefix when getting/setting options
      Returns:
      false if it already exists; if true, caller must save opts
      Throws:
      IOException - on creation fail
    • verifyKeyStore

      public static boolean verifyKeyStore(Properties opts, String optPfx, Set<String> altNames) throws IOException
      Create a new selfsigned cert and keystore and pubkey cert if they don't exist. May take a while.
      Parameters:
      opts - in/out, updated if rv is true
      optPfx - add this prefix when getting/setting options
      altNames - the Subject Alternative Names. May be null. May contain hostnames and/or IP addresses. cname, localhost, 127.0.0.1, and ::1 will be automatically added.
      Returns:
      false if it already exists; if true, caller must save opts
      Throws:
      IOException - on creation fail
    • createKeyStore

      private static boolean createKeyStore(File ks, Properties opts, String optPfx, Set<String> altNames)
      Create a new keystore with a keypair in it.
      Parameters:
      ks - used in CNAME
      opts - in/out, updated if rv is true, must contain PROP_KEY_ALIAS
      optPfx - add this prefix when getting/setting options
      altNames - the Subject Alternative Names. May be null. May contain hostnames and/or IP addresses. cname, localhost, 127.0.0.1, and ::1 will be automatically added.
      Returns:
      success, if true, opts will have password properties added to be saved
    • exportCert

      private static void exportCert(File ks, String name, Properties opts, String optPfx)
      Pull the cert back OUT of the keystore and save it as ascii so the clients can get to it.
      Parameters:
      ks - the keystore file holding the certificate
      name - used to generate output file name
      opts - must contain optPfx + PROP_KEY_ALIAS
      optPfx - add this prefix when getting options
    • initializeFactory

      public static SSLServerSocketFactory initializeFactory(Properties opts) throws IOException
      Sets up the SSLContext and sets the socket factory. No option prefix allowed.
      Parameters:
      opts - tunnel client options, read without a prefix for the keystore name,
      Returns:
      factory, throws on all errors
      Throws:
      IOException - GeneralSecurityExceptions are wrapped in IOE for convenience the key password and the keystore password
    • error

      private static void error(String s)
      Logs an error message.
      Parameters:
      s - the error message
    • logAlways

      private static void logAlways(String s)
      Logs a message the console always shows.
      Parameters:
      s - the message to show