我們使用我們自己的自定義密鑰倉庫,並使用JSSEImplementation和ServerSocketFactory提供了自定義類實現,並在server.xml中爲「store」和「sslImplementation」屬性配置了這兩個自定義類實現。升級到tomcat 8.5時使用自定義密鑰倉庫和jsseimplementation
但現在升級到8.5,我開始大量的ClassNotFoundException爲JSSESocketFactory等
做一點研究,我發現,他們已經拆了很多的類和方法,如JSSESocketFactory.java,getServerSocketFactory(),getSSLUtil(AbstractEndpoint端點)等
所以,現在,我的問題是:
是那裏的Apache Tomcat 8.5的任何方式,我可以在server.xml
配置下的「商店」我的自定義密鑰存儲和使用自己的sslImplementation?
我用AbstractEndpoint方法簽名拿到店裏名server.xml
集,然後加載像這樣MyJSSESocketFactory密鑰庫:
public class MySSLImplementation extends JSSEImplementation
{
@Override
public org.apache.tomcat.util.net.ServerSocketFactory getServerSocketFactory(
AbstractEndpoint endpoint) {
kStore = endpoint.getProperty("store");
return new MyJSSESocketFactory(endpoint, kStore);
}
}
public class MyJSSESocketFactory extends JSSESocketFactory {
private final AbstractEndpoint _endpoint;
private final String store;
public MyJSSESocketFactory(AbstractEndpoint endpoint, String store) {
super(endpoint);
this._endpoint = endpoint;
this.store = store;
}
/*
* Gets the SSL server's keystore.
*/
@Override
protected KeyStore getKeystore(String type, String provider, String pass)
throws IOException {
if ("MYKS".equalsIgnoreCase(type)) {
String keystoreName = store;
KeyStore ks = null;
try {
if (provider == null || provider.isEmpty()) {
ks = KeyStore.getInstance(type);
} else {
ks = KeyStore.getInstance(type, provider);
}
MyStoreParameter params = new MyStoreParameter(
keystoreName);
ks.load(params);
} catch (Exception ex) {
throw new IOException(
"Failed to load keystore " + keystoreName, ex);
}
return ks;
} else {
return super.getKeystore(type, provider, pass);
}
}
}
「MYKS」在server.xml中設置「存儲」屬性
你好:我相信答案是 「是」,而解決方案是定義使用JSSE自己的自定義(VS 。顯然現在已經過時的Tomcat API)。我只能找到一篇關於如何做到這一點的文章:http://www.angelfire.com/or/abhilash/site/articles/jsse-km/customKeyManager.html – paulsm4
我很好奇.. 。爲什麼你需要自己的'SocketFactory'? –