我正在尝试使用 Android 设备上的 apache DefaultHttpClient 连接到本地 HTTPS 服务器。
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://192.168.1.121:4113/services");
... header and content filling in ...
HttpResponse response = httpclient.execute(httppost);
当 .execute 运行时,我收到“javax.net.ssl SSLException:不受信任的服务器证书”错误。我只想允许任何证书工作,无论它是否在 android 密钥链中。
我花了大约 40 个小时研究并试图找出解决此问题的方法。我已经看到了很多如何做到这一点的例子,但到目前为止还没有一个在 Android 中起作用;它们似乎只适用于 JAVA。有谁知道如何配置或覆盖 Android 中 Apache HttpClient 使用的证书验证,以便它只批准 DefaultHttpClient 连接的所有证书?
我感谢你的友好回应