java.lang.Object
net.i2p.sam.client.SSLUtil

class SSLUtilextends Object
Utilities for SAM SSL server sockets.
  • Field Details

  • Constructor Details

    • SSLUtil

      SSLUtil()
      The keystore helpers and 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
    • createKeyStore

      private static boolean createKeyStore(File ks, Properties opts)
      Call out to keytool to create a new keystore with a keypair in it.
      Parameters:
      ks - the keystore file to create
      opts - in/out, updated if rv is true, must contain PROP_KEY_ALIAS
      Returns:
      success, if true, opts will have password properties added to be saved
    • exportCert

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

      public static SSLServerSocketFactory initializeFactory(Properties opts) throws IOException
      Sets up the SSLContext and sets the socket factory. No option prefix allowed.
      Parameters:
      opts - client configuration properties, read without an option prefix
      Returns:
      factory, throws on all errors
      Throws:
      IOException - GeneralSecurityExceptions are wrapped in IOE for convenience
    • 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 client always shows.
      Parameters:
      s - the message to show