// Can be changed by "keystore.type" in JAVA_HOME/lib/security/java.security, defaults to "jks"
// "JKS" in caps works ok on java 1.4.x.. on java 1.5 you must use "jks" in lowercase
String storeType = address.getEnv("keystore.type", java.security.KeyStore.getDefaultType()).getValue();
{ // keyStore with my private key
FileLocator locator = new FileLocator(glob);
URL url = locator.findFileInXmlBlasterSearchPath((String)null, keyStore);
if (url != null) {
InputStream in = url.openStream();
java.security.KeyStore ks = java.security.KeyStore.getInstance(storeType); // since JDK 1.2
ks.load(in, keyStorePassword.toCharArray());
kmf = javax.net.ssl.KeyManagerFactory.getInstance(javax.net.ssl.KeyManagerFactory.getDefaultAlgorithm());
kmf.init(ks, keyStorePassword.toCharArray());
if (firstKey) {
log.info("SSL client socket keyStore="+url.getFile().toString());
firstKey = false;
}
}
else {
log.warning("SSL client socket can't find keyStore=" + keyStore + " in xmlBlaster search pathes, see http://www.xmlblaster.org/xmlBlaster/doc/requirements/protocol.socket.html#SSL");
}
}
{ // trustStore with others public keys
FileLocator locator = new FileLocator(glob);
URL url = locator.findFileInXmlBlasterSearchPath((String)null, trustStore);
if (url != null) {
InputStream in = url.openStream();
java.security.KeyStore ks = java.security.KeyStore.getInstance(storeType);
ks.load(in, trustStorePassword.toCharArray());
tmf = javax.net.ssl.TrustManagerFactory.getInstance(javax.net.ssl.TrustManagerFactory.getDefaultAlgorithm());