“SSLPeerUnverifiedException:没有对等证书”android后端

时间:2012-03-11 06:14:56

标签: android http-get

所以这是我为学校做的一个项目,我们需要一个后端。 我们当前的设置是前台是一个Android应用程序,而后端是一个mySQL数据库,位于我学校的服务器中。 Android应用程序应该使用php脚本与mySQL数据库进行交互。

我的php脚本目前设置为硬编码,以JSON格式从mySQL数据库返回一行。

我的android代码如下:

public static final String KEY = "URL of my PHP script";
InputStream is = null;
String result = "";
try{

        HttpClient httpclient = new DefaultHttpClient();
        HttpGet request = new HttpGet();
        request.setURI(new URI(KEY));
        Log.d(null,"there");
        HttpResponse response = httpclient.execute(request);
        Log.d(null, "here");
        HttpEntity entity = response.getEntity();
        is = entity.getContent();

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

但是,我在

行获得了一个例外
HttpResponse response = httpclient.execute(request);

其中的错误是:没有对等证书。

任何人都知道它有什么问题,以及如何解决它?

1 个答案:

答案 0 :(得分:0)

我有同样的问题。此链接可满足我的部分需求。 http://www.knowledgebit.appspot.com/zahangirbd/TopicView.action;jsessionid=E2BZt_6bp4uFFbMyq42gWg?id=56001

然而,某些链接仍然存在问题(我相信我没有提供适当的证书)

编辑:事实证明证书的顺序是问题所在。

检查一下,这对我有帮助.. Apache HttpClient on Android producing CertPathValidatorException (IssuerName != SubjectName)

相关问题