我需要用我自己的實現來替換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