java.lang.Object
net.i2p.sam.client.SSLUtil
Utilities for SAM SSL server sockets.
Field Summary
Modifier and TypeFieldDescriptionprivate static final StringSuffix of the exported ASCII certificate.private static final StringDirectory holding the exported certificates.static final StringName of the config file in the I2P config dir holding the samclient certificate and key settings.private static final StringDirectory holding the keystores.private static final StringSuffix of the keystore file names.private static final StringPrefix of the client keystore names.private static final StringProperty of the key alias.private static final StringProperty of the key password.private static final StringProperty of the keystore password.private static final StringProperty of the keystore file name.Constructor Summary
ConstructorsConstructorDescriptionSSLUtil()The keystore helpers and socket factories below are static, and the only fields are property-name constants, so an instance carries nothing.Method Summary
Modifier and TypeMethodDescriptionprivate static booleancreateKeyStore(File ks, Properties opts) Call out to keytool to create a new keystore with a keypair in it.private static voidLogs an error message.private static voidexportCert(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.static SSLServerSocketFactoryinitializeFactory(Properties opts) Sets up the SSLContext and sets the socket factory.private static voidLogs a message the client always shows.static booleanverifyKeyStore(Properties opts) Create a new selfsigned cert and keystore and pubkey cert if they don't exist.
Field Details
DEFAULT_SAMCLIENT_CONFIGFILE
Name of the config file in the I2P config dir holding the samclient certificate and key settings.- See Also:
PROP_KEYSTORE_PASSWORD
Property of the keystore password.- See Also:
PROP_KEY_PASSWORD
Property of the key password.- See Also:
PROP_KEY_ALIAS
ASCII_KEYFILE_SUFFIX
Suffix of the exported ASCII certificate.- See Also:
PROP_KS_NAME
Property of the keystore file name.- See Also:
KS_DIR
PREFIX
Prefix of the client keystore names.- See Also:
KS_SUFFIX
Suffix of the keystore file names.- See Also:
CERT_DIR
Directory holding the exported certificates.- See Also:
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
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
Call out to keytool to create a new keystore with a keypair in it.- Parameters:
ks- the keystore file to createopts- 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
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 exportname- used to generate output file nameopts- must contain PROP_KEY_ALIAS
initializeFactory
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
logAlways
Logs a message the client always shows.- Parameters:
s- the message to show