0
我用來使我的連接到PHP的MySQL的HTTP,現在我被要求使用HTTPS,因爲它更安全。但我嘗試了很多方法,但不能讓平板電腦發佈或獲取任何信息,我做了一個自簽名證書,並添加到本地計算機的信任區域,所以我不會被要求它沒有驗證,我想繼續,我嘗試通過瀏覽器連接,它工作正常,打印我需要的所有信息,但不是通過應用程序。我附加了我需要更改爲HTTPS的先前HTTP代碼。想要幫助將此連接更改爲HTTPS。Android:HTTPS連接到我的數據庫
httpclient = new DefaultHttpClient();
httppost = new HttpPost ("http://xx.xx.xx.xx/E-MENU/login.php");
username = etUser.getText().toString();
password = etPass.getText().toString();
password = md5(SHA1(password));
try{
nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("username", username));
nameValuePairs.add(new BasicNameValuePair("password", password));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
response = httpclient.execute(httppost);
if(response.getStatusLine().getStatusCode() == 200){
entity = response.getEntity();
if (entity!= null){
InputStream instream = entity.getContent();
JSONObject jsonResponse = new JSONObject (convertStreamToString(instream));
謝謝前鋒。
其實我不知道如何將我的連接轉換「改變我的HTTP連接」到HTTPS。不知道HTTPS連接設置的代碼 – 2013-02-28 17:57:01
在您的URL(在新的HTTPPost(「...」)中定義)中將http://更改爲https://。 – nmw 2013-02-28 18:04:49