我的 Android 应用程序出现问题,在我使用 volley 进行网络请求的其中一个片段中:
JsonObjectRequest request = new JsonObjectRequest(
Request.Method.POST,
CustomNetworkManager.getInstance(this.getActivity().getApplicationContext()).getRequestUrl(url),
requestData,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
// process response
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.d("FeedFragment", "Volley error: " + error.toString());
}
});
在真实设备上出现以下错误(运行 API23):
D/FeedFragment: Volley error: com.android.volley.NoConnectionError: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
在运行相同 API 版本的 AVD 中,它工作正常。我检查了其他类似的线程,但找不到答案。
谢谢你的帮助。
编辑:如果有人遇到同样的错误,请确保您的证书没有任何问题( http://developer.android.com/intl/pt-br/training/articles/security-ssl.html#CommonProblems )
原文由 Sammy Patenotte 发布,翻译遵循 CC BY-SA 4.0 许可协议
尝试将此功能添加到您的应用程序中:
然后在您的应用程序 onCreate 中调用它。
更新: