我在glassfish服務器中有一些簡單的Web服務應用程序,其中請求需要證書授權。有幾個證書。我想使用取決於ID:該作品在GlassFish:證書未正確加載在weblogic服務器上部署的jax-ws webservices
MyCustomPortType service;
...
// set certifikate
setSSLSocketFactory(id, (BindingProvider) service);
// send request
final MyCustomType response = service.process(params);
現在我需要部署在WebLogic這個應用程序,並在這裏就是問題所在。現在只需傳遞帶有第一個id和其他請求返回錯誤的請求,因爲它們的證書不正確。我認爲,在weblogic有一些高速緩存,其錯過GlassFish和要求中仍包含甚至SSLSocketFactory的是不同的同一證書
UPDATE:
我讀這篇文章:http://docs.oracle.com/cd/E13222_01/wls/docs92/secmanage/ssl.html#wp1194460,但我不知道如何實現這個在我的應用
UPDATE2:
protected void setSSLSocketFactory(final String agenda, final BindingProvider service) {
service.getRequestContext().put(JAXWSProperties.SSL_SOCKET_FACTORY,
MutualSSLContext.getFactory(configuration, agenda));
}
public static final SSLSocketFactory getFactory(final RobaktConfiguration cfg, final String agenda) {
if (cfg == null || agenda == null) {
return null;
}
try {
final File keyStore = cfg.getKeystorePath(agenda);
final KeyManager[] keyManagers;
if (keyStore != null) {
keyManagers = new KeyManager[] {new MutualKeyManager(cfg, agenda)};
} else {
keyManagers = null;
}
final SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(keyManagers, new TrustManager[] {new MutualTrustManager()}, null);
final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
return sslSocketFactory;
} catch (Exception e) {
throw new MutualSSLException(e.getMessage(), e);
}
}
MutualKeyManager
類implem ent接口X509ExtendedKeyManager
。我不能在這裏添加它
幾個問題給出正確的答案: 2.如何實現'setSSLSocketFactory'?你可以發佈一些代碼嗎? – secra
nope,問題已更新 – hudi