2009-09-25 47 views
1

我想最後在一個獨立的應用程序,這些線路沒有異常拋出經過:如何使用t3s連接到Weblogic JMS隊列?

Properties props = new Properties(); 
    props.setProperty("java.naming.factory.initial", 
         "weblogic.jndi.WLInitialContextFactory"); 
    props.setProperty("java.naming.provider.url", 
         "t3s://localhost:9002"); 
    props.setProperty("java.naming.security.principal", 
         "<username>"); 
    props.setProperty("java.naming.security.credentials", 
         "<password>"); 
    Context ctx = new InitialContext(props); 

...但我得到一個異常信息:

Warning Security BEA-090542 Certificate chain received from localhost - 127.0.0.1 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.

所以,我創建使用該命令爲CA密鑰庫:

keytool -keystore client.jks -importcert -file cacert.pem

...和使用屬性稱爲它weblogic.security.TrustKeyStore = client.jks

這仍然不起作用,很可能是因爲我沒有向密鑰庫提供密碼。我錯過了什麼?我怎樣才能提供這個密碼? (或者,如何在不設置密碼的情況下創建密鑰庫?)

+0

您是否在管理控制檯中設置了隊列和連接工廠? – duffymo 2009-09-25 21:58:04

+0

是的,一切正常,使用t3協議,沒有ssl。使用t3s,我從來沒有通過jndi查找。創建InitialContext實例時,會在ssl握手時拋出異常。 – davidi 2009-09-26 06:26:30

回答

8

差不多兩個月後,我又回到了這個問題。發現this link後,我發現,這個工程:

 System.setProperty("weblogic.security.SSL.ignoreHostnameVerification","true"); 
     System.setProperty("java.protocol.handler.pkgs", "weblogic.net"); 
     System.setProperty("weblogic.security.TrustKeyStore","CustomTrust"); 
     System.setProperty("weblogic.security.CustomTrustKeyStoreFileName", "<keystorelocation>"); 
     System.setProperty("weblogic.security.CustomTrustKeyStorePassPhrase","<keystorepassword>"); 
     System.setProperty("weblogic.security.CustomTrustKeyStoreType","JKS"); 

我只得到它的工作使用的系統屬性。