【发布时间】:2015-09-06 04:16:03
【问题描述】:
我正在尝试使用 HTTPS 实现 Android ↔ Apache 通信,但出现以下错误。我间歇性地遇到这个问题,大约有 30% 的时间。
javax.net.ssl.sslPeerUnverifiedException: No peer certificate
我在网上搜索过,但任何答案都对我有所帮助...
这是我的 Android 代码:
http_post = new HttpPost(Utils.IP_ADDRESS);
http_post_data = new ArrayList<NameValuePair>();
http_post_data.add(new BasicNameValuePair("regId", regid));
http_post_data.add(new BasicNameValuePair("email", globals.userInfo.mail));
http_post_data.add(new BasicNameValuePair("pass", globals.userInfo.pass));
http_post.setEntity(new UrlEncodedFormEntity(http_post_data));
HttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters, Utils.TIMEOUT_CONNECTION);
HttpConnectionParams.setSoTimeout(httpParameters, Utils.TIMEOUT_SOCKET);
http_client = new DefaultHttpClient(httpParameters);
response = http_client.execute(http_post);
String responseBody = EntityUtils.toString(response.getEntity(), GlobalsSingleton.applicationCharset);
我有 GoDaddy 证书。那么我需要在我的服务器或 Android 代码中进行哪些更改才能修复此问题?
【问题讨论】:
-
@Fernando - 您需要能够复制问题才能解决问题。对于故障排除,请使用
openssl s_client -connect host:port -tls1 -servername host。此外,您需要发布详细信息,例如 URL 或服务器名称,以便我们尝试复制它。拒绝我们提供详细信息没有任何用处,因为该服务器位于网络上,供坏人攻击。 -
@Fernando - 网站托管在哪里,是否负载平衡?另请参阅
SSLSocketFactoryEx以确保您从 Android 获得配置良好的 SSL/TLS 套接字。您可以在Which Cipher Suites to enable for SSL Socket? 找到它
标签: android apache ssl https ssl-certificate