0

我正在尝试在 https url 上发布一些数据,该 url 没有证书,因为那只是 web 服务,我的代码在下面给出

DefaultHttpClient hc=new DefaultHttpClient();   
ResponseHandler <String> res=new BasicResponseHandler();
String   sourceURL=context.getResources().getString(R.string.web_service_url)+"/authenticateUser";
    Log.d("INSIDE AUTHENTICATION", "URLSOFAuthenticateuser" +sourceURL);
    HttpPost postMethod=new HttpPost(sourceURL);   
    List<NameValuePair> userDetails = new ArrayList<NameValuePair>();

    userDetails.add(new BasicNameValuePair("userId", userId)); 
    userDetails.add(new BasicNameValuePair("userPass", userPass)); 

    try {

        Log.d("inside", "&*&*&*&*"+userDetails);
        postMethod.setEntity(new UrlEncodedFormEntity(userDetails)); 
        Log.d("iNSIDE 1", "&*&*&*"+hc.execute(postMethod,res));
        response=hc.execute(postMethod,res);
        Log.d("iNSIDE 2", "&*&*&*");



    }
    catch(HttpResponseException g)
    {
        Log.d("", "&*&*&*HttpResponseException");
    }
    catch (UnsupportedEncodingException e) {
        Log.d("", "&*&*&*UnsupportedEncodingException");

    } catch (ClientProtocolException e) {
        Log.d("", "&*&*&*ClientProtocolException");


    } catch (IOException e) {
        Log.d("", "&*&*&*IOException");

    }  
       return response;  

你能帮我解决这个问题吗?有什么方法可以在 https 网址上发布 httppost。谢谢

4

1 回答 1

1

http://blog.crazybob.org/2010/02/android-trusting-ssl-certificates.html

这应该会有所帮助..如果您仍然遇到问题,请告诉我。

于 2012-11-05T14:10:07.890 回答