作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试从网站 https://songbpm.com/tiesto/red+lights 下载网站内容但是由于证书问题,没有收到内容该内容稍后将用于从 Android 应用程序获取某些歌曲的 bpm。
连接代码
AsyncHttpPost post = new AsyncHttpPost();
post.execute("https://songbpm.com/tiesto/red+lights");
TextView tv = (TextView)findViewById(R.id.textview1);
tv.setText("Hello,"+post.get().toString()+",");
异步 http post 类,因为它在一个单独的线程中
byte[] result = null;
String str = "";
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(params[0]);
try {
HttpResponse response = client.execute(post);
StatusLine statusLine = response.getStatusLine();
if(statusLine.getStatusCode() == HttpURLConnection.HTTP_OK){
result = EntityUtils.toByteArray(response.getEntity());
str = new String(result, "UTF-8");
}
}
最佳答案
我之前遇到过同样的问题。我使用了这样的解决方法: Trusting all certificates using HttpClient over HTTPS
添加 MySSLSocketFactory 后,它可以正常工作。所以这可能对您有所帮助。
注意:这不是一个非常安全的解决方案。仅将其用于测试目的。
关于javax.net.ssl.SSLPeerUnverifiedException : No peer certificate when downloading website content android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31005108/
我是一名优秀的程序员,十分优秀!