我们有一个应用程序,可以在API中查询显示给用户的类别列表。我们收到了一位用户的崩溃报告,指出该应用已因SSLPeerUnverifiedException而崩溃:
ANDROID_VERSION=4.4.4
APP_VERSION_NAME=1.12
BRAND=Xiaomi
PHONE_MODEL=2014818
CUSTOM_DATA=
STACK_TRACE=java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.RuntimeException: javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
at fr.free.nrw.commons.category.PrefixUpdater.doInBackground(PrefixUpdater.java:66)
导致崩溃的相关代码是:
protected ArrayList<String> doInBackground(Void... voids) {
//otherwise if user has typed something in that isn't in cache, search API for matching categories
MWApi api = CommonsApplication.createMWApi();
ApiResult result;
ArrayList<String> categories = new ArrayList<String>();
try {
result = api.action("query")
.param("list", "allcategories")
.param("acprefix", filter)
.param("aclimit", catFragment.SEARCH_CATS_LIMIT)
.get();
Log.d(TAG, "Prefix URL filter" + result.toString());
} catch (IOException e) {
throw new RuntimeException(e);
}
我不认为问题是服务器端的,因为查询的URL具有适当的证书,并且在数百个应用程序使用中,这是第一个似乎遇到此问题的用户。查询的网址为https://commons.wikimedia.org/w/api.php?action=query&list=allcategories&acprefix=filter&aclimit=25,其中包含&#39;过滤器&#39;取而代之的是用户的文字。
解决此问题的推荐方法是什么?我在javax.net.ssl.sslpeerunverifiedexception no peer certificate找到了一个解决方案,但我们宁愿避免这种情况,因为应用程序通过公共网络传输数据,我们有安全问题。