Disable SSL certificate check in retrofit library

前端 未结 8 1513
谎友^
谎友^ 2020-11-29 05:41

I am using retrofit in android to connect with server.

public class ApiClient {
    public static final String BASE_URL = \"https://example.com/\";
    priva         


        
8条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 06:13

    I strongly discourage doing this

    Short answer - subclass HostNameVerifier, over-ride verify() to always return true.

    This has better options

    Long answer - check my (getting pretty old) blog here: Making Android and SSL Work Together

    Maybe the best option for your scenario

    Drop the https to http for your test server, then the logic doesn't have to change.

    HTH

提交回复
热议问题