设置:WL的Jrockit上的WL 9.2 Jersey 1.1.5.1.
Picked Jersey 1.1.5.1因为新版本需要
Java 6,我相信.
Weblogic EJB充当REST客户端并不断收到此错误:
ClientHandlerException: javax.net.ssl.SSLKeyException: [Security:090477]Certificate chain received from svcpoint.restprovider.com – xx.xxx.xxx.xx was not trusted causing SSL handshake failure.
由于这只是一个POC实现,Weblogic设置了各种标志,以忽略证书验证只是为了使这个错误消失:
-Dweblogic.security.SSL.ignoreHostnameVerification=true -Dweblogic.security.SSL.enforceConstraints=off -Dweblogic.webservice.client.ssl.strictcertchecking=false
此外,Jersey配置设置包括以下内容:
SSLContext ctx = SSLContext.getInstance("SSL");
HTTPSProperties prop = new HTTPSProperties(
new HostnameVerifier () {
public boolean verify(String hostname, SSLSession session) {
System.out.println("\n\nFAKE_Verifier: " + hostname+"\n\n");
return true;
}
}, ctx);
config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, prop);
最后,唯一的WL服务器,技术上是admin srv,在管理控制台SSL.Advanced设置中配置为不使用主机名验证.
现在,我非常确定Jersey的假验证器设置实际上并没有涉及,因为我从SSL调试中看到了这个错误:
<SecuritySSL> <000000> <weblogic user specified trustmanager validation status 16>
<Security> <BEA-090477> <Certificate chain received from svcpoint.restprovider.com - xx.xxx.xxx.xx was not trusted causing SSL handshake failure.>
<SecuritySSL> <000000> <Validation error = 16>
<SecuritySSL> <000000> <Certificate chain is untrusted>
<SecuritySSL> <000000> <SSLTrustValidator returns: 16>
<SecuritySSL> <000000> <Trust status (16): CERT_CHAIN_UNTRUSTED>
<SecuritySSL> <000000> <NEW ALERT with Severity: FATAL, Type: 42
java.lang.Exception: New alert stack
at com.certicom.tls.record.alert.Alert.<init>(Unknown Source)
我在谷歌搜索并查看其他类似问题,但我可能遗漏了一些东西.此外,从我可以判断证书似乎是有效的,显示它是CN = * .restprovider.com,2011年11月到期.
最佳答案 证书不受信任.我认为最好的解决方案是使用keytool将其添加到Weblogic的信任存储中:
keytool -importcert -trustcacerts ...
您也可以在代码中执行此操作:
TrustManagerFactory trustManagerFactory = TrustManagerFactory
.getInstance("SunX509");
trustManagerFactory.init(trustStore);
trustManagers = trustManagerFactory.getTrustManagers();
SSLContext context = SSLContext.getInstance("TLS");
context.init(keyManagers, trustManagers, new SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory());
trustStore – 是包含证书的密钥库