2012-04-07 172 views
0

我已經創建了帶有私鑰的證書和密鑰庫的信任關係。 我已經把下面的代碼,加載了trsustore管理器和keystore管理器,然後創建SSL上下文的實例。2路SSL :: SSL握手失敗錯誤

當我向webservice發出請求時,會調用以下代碼。 我們正在使用axis2 API。

SSLContext context = SSLContext.getInstance(protocolVersion); 
context.init(keyManagers, trustManagers, null); 

SSLSocketFactory socketFactory = context.getSocketFactory(); 

SslContextedSecureProtocolSocketFactory secureProtocolSocketFactory = new SslContextedSecureProtocolSocketFactory(context); 

Protocol authhttps = new Protocol("https", secureProtocolSocketFactory, port); 
HttpClient httpclient = new HttpClient(); 
httpclient.getHostConfiguration().setHost(hostname, port, authhttps); 
GetMethod httpget = new GetMethod("/RTAPService/RTAPService"); 

試圖與此以及 GetMethod HTTPGET =新GetMethod( 「/」);

httpclient.executeMethod(httpget); 

它給了我下面的錯誤..

org.apache.axis2.AxisFault: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 

其中hostname是 「qartap.csnet.assurity.sg」 和我的web服務URL爲 「https://qartap.csnet.assurity.sg:8443/RTAPService/RTAPService

問題是,當我註冊我的「HTTPS」協議,它影響我的整個應用程序,我可以以某種方式設置這些僅適用於特定的主機或特定的web服務。

要麼我想設置此使用主機名或創建新的協議本身...我嘗試瞭解決方案中給出的方法here。但它給了我下面的例外..

雖然將Web服務URl傳遞到生成的存根構造函數,我用我自己定製的「myHTTPS」從URL替換「HTTPS」。

The system cannot infer the transport information from the myhttps://serverUrl:7001/app/services/RTAPDevService.RTAPDevServiceHttpSoap12Endpoint/ URL. 
+1

當你嘗試過什麼事?當然8433應該是8443? – EJP 2012-04-07 11:10:02

+0

「* [*]可在互聯網上的其中一個罐子*上使用*。互聯網上有很多罐子。我想你說的是[this](http://code.google.com/p/jsslutils/wiki/ApacheHttpClientUsage)。 – Bruno 2012-04-07 12:32:44

+0

我已經包含了上面提到的代碼,並給予客戶端發佈..Monday他們會測試它,如果它工作或我會回覆你或錯誤,我不能從本地環境訪問webservice由於安全原因。 ...我只想問你是否還需要除了上面提到的代碼之外還有其他任何東西...是的端口是8443,我正在使用鏈接中提到的jar文件.... – 2012-04-07 17:05:11

回答