2013-01-04 20 views
0

使用HTTP組件HTTPClient 4項目來處理HTTP GET方法的最佳方式是什麼? 什麼是參數化認證信息的最佳途徑?屬性文件?重新加載方法到守護程序服務?帶有https的HTTP客戶機

HttpClient httpClient = new DefaultHttpClient(); 
    String url = "https://xxx.190.2.45/index.jsp"; 
    HttpGet get = new HttpGet(url); 
    try { 
        //TODO 
        HTTPHelper.addSSLSupport(httpClient); 
     HttpResponse response = httpClient.execute(get); 

     BasicResponseHandler responseHandler = new BasicResponseHandler(); 
     String responseString = responseHandler.handleResponse(response); 

    } catch (ClientProtocolException e) { 
     throw new RuntimeException(e); 
    } catch (IOException e) { 
     throw new RuntimeException(e); 
    } 

回答

1

你需要啓用SSL支持,請參閱tutorial以獲取更多信息

我就是你正在使用的服務器的自簽名證書的印象。你可能應該做的是看看openssl,生成一個CA &服務器證書。將CA證書(不是私鑰)放入「信任存儲區」並配置套接字工廠。

如果您需要更多詳細信息,請點擊此處,我​​會再補充一些。我在簡單的本地項目中取得了巨大的成功!