【问题标题】:Unable to upload strings with httpClient to my SSL server无法使用 httpClient 将字符串上传到我的 SSL 服务器
【发布时间】:2018-07-18 01:21:59
【问题描述】:

我正在尝试使用 php Web 服务将一些文本上传到我的服务器,而我的服务器具有 ssl 证书。当我尝试另一台没有 ssl 的服务器时,它可以正常工作。

谁能帮我解决这个问题?我在这个论坛上搜索了一整天。

请不要告诉我这是重复的问题(帮助初学者程序员)

这是我的代码:

 protected String doInBackground(Void... params) {

        ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
        nameValuePairs.add(new BasicNameValuePair("base64", ba1));
        nameValuePairs.add(new BasicNameValuePair("ImageName", System.currentTimeMillis() + ".jpg"));
        nameValuePairs.add(new BasicNameValuePair("arrondi",arrondi));
        nameValuePairs.add(new BasicNameValuePair("controleur",controleur));

        try {

            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost(URL);
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"));
            HttpResponse response = httpclient.execute(httppost);
            String st = EntityUtils.toString(response.getEntity());
            Log.v("log_tag", "In the try Loop" + st);

        } catch (Exception e) {
            Log.v("log_tag", "Error in http connection " + e.toString());
        }
        return "Success";

    }

【问题讨论】:

  • 欢迎来到 Stack Overflow!请编辑您的问题以显示您遇到的错误,否则没有人会知道从哪里开始帮助您。

标签: php android ssl androidhttpclient


【解决方案1】:

请尝试绕过 SSL 证书并再试一次,我认为它应该可以工作.. How to bypass ssl certificate checking in java

Android ignore self signed certificate

【讨论】:

    猜你喜欢
    • 2014-08-20
    • 1970-01-01
    • 1970-01-01
    • 2018-02-14
    • 2011-02-17
    • 2016-12-18
    • 1970-01-01
    • 2014-03-07
    • 1970-01-01
    相关资源
    最近更新 更多