How to fix unsafe implementation of X509TrustManager in Android app

后端 未结 5 1876
被撕碎了的回忆
被撕碎了的回忆 2020-12-04 13:31

Google has advised that I have an unsafe implementation of the interface X509TrustManager in my Android application and need to change my code as follows:

5条回答
  •  既然无缘
    2020-12-04 14:02

    If you encounter this from external library you're using, check if appache libraray is the cause of it.

    For me apache library caused the error : i was using deprecated class - MultipartEntity. This class uses SSLContextBuilder which uses TrustManagerDelegate. TrustManagerDelegate implements X509TrustManager, which cause "unsafe implementation of TrustManager" error when uploading application to google play store.

    The solution is : instead of deprecated MultipartEntity class, use MultipartEntityBuilder.

    For example :

    MultipartEntity httpMultipart = new MultipartEntity();
    String contentType = httpMultipart.getContentType().getValue();
    

    Will be replaced by :

    MultipartEntityBuilder httpMultipart = new MultipartEntityBuilder();
    String contentType = httpMultipart.build().getContentType().getValue();
    

提交回复
热议问题