我在Android中使用JSON时遇到一些问题,它在日志猫中给我一些错误,请帮我解决,我的代码是:
String feedUrl= "https://107.170.117.18:7000/infoes/";
Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
context=this;
infoListTask loaderTask = new infoListTask();
loaderTask.execute();
}
private class infoListTask extends AsyncTask<Void,Void,Void> {
ProgressDialog dialog;
@Override
protected void onPreExecute() {
dialog= new ProgressDialog(context);
dialog.setTitle("Loading ...");
dialog.show();
super.onPreExecute();
}
@Override
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
HttpClient client = new DefaultHttpClient();
HttpGet getRequest = new HttpGet(feedUrl);
try {
HttpResponse response =client.execute(getRequest);
StatusLine statusline= response.getStatusLine();
int statusCode= statusline.getStatusCode();
if(statusCode != 200){
return null;
}
InputStream jsonStream = response.getEntity().getContent();
BufferedReader reader= new BufferedReader(new InputStreamReader(jsonStream));
StringBuilder builder = new StringBuilder();
String line;
while((line= reader.readLine()) != null)
{
builder.append(line);
}
String jsonData= builder.toString();
Log.i("You json Data", jsonData);
}
catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e) {
//TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
// TODO Auto-generated method stub
dialog.dismiss();
//videoAdapter.notifyDataSetChanged();
super.onPostExecute(result);
}
}
这是我的日志猫:
06-17 11:55:50.361: W/System.err(2224): javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
06-17 11:55:50.397: W/System.err(2224): at com.android.org.conscrypt.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:146)
06-17 11:55:50.409: W/System.err(2224): at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:93)
06-17 11:55:50.413: W/System.err(2224): at org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:388)
06-17 11:55:50.413: W/System.err(2224): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:165)
06-17 11:55:50.413: W/System.err(2224): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
06-17 11:55:50.413: W/System.err(2224): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
06-17 11:55:50.417: W/System.err(2224): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
06-17 11:55:50.417: W/System.err(2224): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
06-17 11:55:50.421: W/System.err(2224): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
06-17 11:55:50.421: W/System.err(2224): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
06-17 11:55:50.421: W/System.err(2224): at com.amirhossein.test.MainActivity$infoListTask.doInBackground(MainActivity.java:78)
06-17 11:55:50.421: W/System.err(2224): at com.amirhossein.test.MainActivity$infoListTask.doInBackground(MainActivity.java:1)
06-17 11:55:50.421: W/System.err(2224): at android.os.AsyncTask$2.call(AsyncTask.java:288)
06-17 11:55:50.425: W/System.err(2224): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
06-17 11:55:50.425: W/System.err(2224): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
06-17 11:55:50.433: W/System.err(2224): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
06-17 11:55:50.437: W/System.err(2224): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
06-17 11:55:50.437: W/System.err(2224): at java.lang.Thread.run(Thread.java:841)
06-17 11:55:50.449: W/EGL_genymotion(2224): eglSurfaceAttrib not implemented
06-17 11:55:50.529: W/EGL_genymotion(2224): eglSurfaceAttrib not implemented
答案 0 :(得分:0)
查看其他问题&#39; SSLPeerUnverifiedException:没有对等证书&#39;:
Safely fixing: javax.net.ssl.SSLPeerUnverifiedException: No peer certificate