2013-06-25 45 views
0

我嘗試運行HTTPS基本服務器身份驗證的Weblogic 10上的一個系統測試,但我收到此異常:試圖獲得基本的Weblogic服務器身份驗證,但我得到這個異常javax.net.ssl.SSLKeyException:[安全性:090542]

com.sun.jersey.api.client.ClientHandlerException: javax.net.ssl.SSLKeyException: [Security:090542]Certificate chain received from myserver - 141.73.205.173 was not trusted causing SSL handshake failure. Check the certificate chain to determine if it should be trusted or not. If it should be trusted, then update the client trusted CA configuration to trust the CA certificate that signed the peer certificate chain. If you are connecting to a WLS server that is using demo certificates (the default WLS server behavior), and you want this client to trust demo certificates, then specify -Dweblogic.security.TrustKeyStore=DemoTrust on the command line for this client. 

在com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:149) 在com.sun.jersey.api.client.filter.HTTPBasicAuthFilter.handle(HTTPBasicAuthFilter.java :81) at com.sun.jersey.api.client.Client.handle(Client.java:648) ........................ .....................

我的身份驗證方法是:

public static WebResource createWebResource(String path) throws IOException, NoSuchAlgorithmException, Exception { 
ClientConfig config = new DefaultClientConfig(); 
Client client = Client.create(config); 
HTTPBasicAuthFilter authFilter = new HTTPBasicAuthFilter("REST_USER", "Supervisor"); 
client.addFilter(authFilter); 
String serverUrl = findServerUrlFromJNDIProps(); 
return client.resource("https://myserver:8012/ERSrestServices/" + path); 

}

哪裏是我的錯?

回答

0

由於java不信任SSL證書,所以它拒絕嘗試通過https訪問服務器。

如果這是一個帶有自簽名證書的測試服務器,這將是有道理的。如果它不是自簽名的,那麼您的java安裝不會信任CA.

按例外:

如果要連接到使用演示證書(默認WLS服務器行爲)一個WLS服務器,並且希望此客戶信任的演示證書,然後指定 -Dweblogic.security.TrustKeyStore = DemoTrust在該客戶端的命令行上。

所以,-Dweblogic.security.TrustKeyStore=DemoTrust應該解決您的問題。

或者你可以添加你的web服務器的SSL證書對客戶端的Java證書存儲區:

keytool -importcert -file certificate.cer -keystore cacerts -alias "Your Alias" 

凡密鑰工具可以在$ {JDK_HOME}/bin並在$ {JDK_HOME} cacerts文件/ JRE中找到/ lib/security

+0

謝謝answear,服務器用於測試目的 –

相關問題