我在 android 中使用改造来连接服务器。
public class ApiClient {
public static final String BASE_URL = "https://example.com/";
private static Retrofit retrofit = null;
public static Retrofit getClient() {
if (retrofit==null) {
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
return retrofit;
}
}
这是我的开发者。服务器,我想禁用证书检查。我怎样才能在这段代码中实现?
错误:javax.net.ssl.SSLHandshakeException:java.security.cert.CertPathValidatorException:找不到证书路径的信任锚。
原文由 Ronak Patel 发布,翻译遵循 CC BY-SA 4.0 许可协议
使用此类获取不安全的 Retrofit 实例。我已经包括进口以避免混淆。
然后像这样简单地使用没有 ssl 检查的改造