Android HTTPS POST给出错误不可信服务器证书
问题描述:
我有以下的Android POST代码。它可以正常工作,但对于不可信服务器证书异常的HTTPS会失败。我不介意自签名或接受所有的证书代码(中间人攻击不太安全)。Android HTTPS POST给出错误不可信服务器证书
HttpPost post = new HttpPost("https://yourdomain.com/yourskript.xyz");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("postValue1", "my Value"));
nameValuePairs.add(new BasicNameValuePair("postValue2", "2nd Value"));
nameValuePairs.add(new BasicNameValuePair("postValue3", "3rd Value"));
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpClient client = new DefaultHttpClient(); HttpResponse response =
client.execute(post); HttpEntity entity = response.getEntity();
String responseText = EntityUtils.toString(entity);
任何帮助在这里感谢。我需要使用postValue1,postValue2和postValue3(至少3)提交POST代码的证书部分。
的问题是我的服务器证书过期。我不得不续约它,并再次安装它,它工作正常!我的印象是更新只是我所要做的。 – user914425