java.lang.Object
net.i2p.i2ptunnel.SSLClientUtil
SSL server socket utilities for I2PTunnel clients.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringSuffix of the exported ASCII certificate.private static final StringDirectory holding the exported certificates.private static final StringDirectory holding the keystores.private static final StringSuffix of the keystore file names.private static final StringPrefix of the tunnel 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
ConstructorsConstructorDescriptionverifyKeyStore(Properties)and the 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, String optPfx, Set<String> altNames) Create a new keystore with a keypair in it.private static voidLogs an error message.private static voidexportCert(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.static SSLServerSocketFactoryinitializeFactory(Properties opts) Sets up the SSLContext and sets the socket factory.private static voidLogs a message the console always shows.static booleanverifyKeyStore(Properties opts) Create a new selfsigned cert and keystore and pubkey cert if they don't exist.static booleanverifyKeyStore(Properties opts, String optPfx) Create a new selfsigned cert and keystore and pubkey cert if they don't exist.static booleanverifyKeyStore(Properties opts, String optPfx, Set<String> altNames) Create a new selfsigned cert and keystore and pubkey cert if they don't exist.
Field Details
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 tunnel 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
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
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
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 trueoptPfx- 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 trueoptPfx- add this prefix when getting/setting optionsaltNames- 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 CNAMEopts- in/out, updated if rv is true, must contain PROP_KEY_ALIASoptPfx- add this prefix when getting/setting optionsaltNames- 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
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 certificatename- used to generate output file nameopts- must contain optPfx + PROP_KEY_ALIASoptPfx- add this prefix when getting options
initializeFactory
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
logAlways
Logs a message the console always shows.- Parameters:
s- the message to show