in common/servicemix-components/src/main/java/org/apache/servicemix/components/http/HttpsInvoker.java [82:137]
public CommonsHttpSSLSocketFactory() throws Exception {
SSLContext context = SSLContext.getInstance(protocol);
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(algorithm);
if (keyStore == null) {
keyStore = System.getProperty("javax.net.ssl.keyStore");
if (keyStore == null) {
throw new IllegalArgumentException("keyStore or system property javax.net.ssl.keyStore must be set");
}
}
if (keyStore.startsWith("classpath:")) {
try {
String res = keyStore.substring(10);
URL url = new ClassPathResource(res).getURL();
keyStore = url.toString();
} catch (IOException e) {
throw new JBIException("Unable to find keyStore " + keyStore, e);
}
}
if (keyStorePassword == null) {
keyStorePassword = System.getProperty("javax.net.ssl.keyStorePassword");
if (keyStorePassword == null) {
throw new IllegalArgumentException("keyStorePassword or system property javax.net.ssl.keyStorePassword must be set");
}
}
if (trustStore == null) {
trustStore = System.getProperty("javax.net.ssl.trustStore");
}
if (trustStore != null && trustStore.startsWith("classpath:")) {
try {
String res = trustStore.substring(10);
URL url = new ClassPathResource(res).getURL();
trustStore = url.toString();
} catch (IOException e) {
throw new JBIException("Unable to find trustStore " + trustStore, e);
}
}
if (trustStorePassword == null) {
trustStorePassword = System.getProperty("javax.net.ssl.trustStorePassword");
if (keyStorePassword == null) {
throw new IllegalArgumentException("trustStorePassword or system property javax.net.ssl.trustStorePassword must be set");
}
}
KeyStore ks = KeyStore.getInstance(keyStoreType);
ks.load(Resource.newResource(keyStore).getInputStream(), keyStorePassword.toCharArray());
keyManagerFactory.init(ks, keyPassword != null ? keyPassword.toCharArray() : keyStorePassword.toCharArray());
if (trustStore != null) {
KeyStore ts = KeyStore.getInstance(trustStoreType);
ts.load(Resource.newResource(trustStore).getInputStream(), trustStorePassword.toCharArray());
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(algorithm);
trustManagerFactory.init(ts);
context.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), new java.security.SecureRandom());
} else {
context.init(keyManagerFactory.getKeyManagers(), null, new java.security.SecureRandom());
}
factory = context.getSocketFactory();
}