我需要用我自己的实现来替换Axis的(1.4)默认SecureSocketFactory。我已经从独立的JRE(1.6)成功运行,并且所有的测试都很好。但是,当我部署到Tomcat 5.5时 - 这个应用程序最终将驻留 - 据我所知,Axis仍在使用JSSESecureSocketFactory。我都试过:在独立JRE和Tomcat中设置axis.SecureSocketFactory
System.setProperty("org.apache.axis.components.net.SecureSocketFactory", "my.CustomSecureSocketFactory");
和
AxisProperties.setProperty("axis.socketSecureFactory", "my.CustomSecureSocketFactory");
以及设置JVM属性为Tomcat:
-Dorg.apache.axis.components.net.SecureSocketFactory=my.CustomSecureSocketFactory
的JRE中,库键/信任存储,和一切否则我能想到的是完全相同的。我甚至在服务器上运行独立测试,使用Tomcat的JRE和选项,并且仍然正常工作。
我不知道如何解决这个问题。有没有人知道在哪里寻找,或者告诉Axis使用特定的SecureSocketFactory的替代方法?
相关代码片段:
public class CustomKeyManager extends X509ExtendedKeyManager {
private final X509ExtendedKeyManager base;
public CustomKeyManager(X509ExtendedKeyManager base) {
this.base = base;
}
/* Lots of methods omitted */
static SSLContext SSL_CONTEXT;
static void updateSSL(String keyStoreFile, String keyStorePassword){
System.setProperty("org.apache.axis.components.net.SecureSocketFactory", "com.spanlink.cfg.crypto.HostNameSecureSocketFactory");
AxisProperties.setProperty("axis.socketSecureFactory", "com.spanlink.cfg.crypto.HostNameSecureSocketFactory");
KeyStore keyStore = KeyStore.getInstance("jks");
keyStore.load(new FileInputStream(keyStoreFile), keyStorePassword.toCharArray());
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(keyStore, keyStorePassword.toCharArray());
KeyManager[] oldManagers = kmf.getKeyManagers();
KeyManager[] newManagers = new KeyManager[oldManagers.length];
for (int i = 0; i < oldManagers.length; i++) {
if (oldManagers[i] instanceof X509ExtendedKeyManager) {
newManagers[i] = new CustomKeyManager((X509ExtendedKeyManager) oldManagers[i]);
}else{
newManagers[i] = oldManagers[i];
}
}
SSL_CONTEXT = SSLContext.getInstance("SSL");
SSL_CONTEXT.init(newManagers, null, null);
}
}
public class CustomSecureSocketFactory extends JSSESocketFactory {
public CustomSecureSocketFactory(Hashtable table) {
super(table);
super.sslFactory = CustomKeyManager.SSL_CONTEXT.getSocketFactory();
}
}
你能否描述你的修复更详细一些?你在Class.forName()调用中使用了什么参数?我想我遇到了同样的问题。我尝试添加“Class.forName(SocketFactoryFactory.class.getCanonicalName());” AxistProperties.setProperty(“axis.socketSecureFactory”,MyCustomSocketFactory.class.getCanonicalName());但它没有解决这个问题。 – CDelaney 2015-02-18 16:12:19
我想出了我的错误。我在设置覆盖和执行覆盖的请求之间执行了不同的请求。它在本地工作,但不在jboss上。我更新它以在请求需要之前立即设置覆盖。 – CDelaney 2015-02-18 17:22:17