我尝试在我的应用程序 Android 中使用 HTTPS 作为 API url,并将以下代码发送到网络服务:
public final class Constants {
public static class Extra {
public static final String api_url = "https://example.co.id/";
public static final String PACKAGE_NAME = "example.co.id";
public static final String token = "some token";
}
}
为什么在我的网站已经在虚拟主机中购买证书 ssl 之前,我尝试运行应用程序会在日志中出现错误(没有对等证书)。
我尝试在谷歌中搜索,尝试搜索最佳实践,但我的情况并没有得到相同的结果并使用keystools,我非常不明白从哪里开始在我的应用程序中添加SSL“https”。
让Android应用程序连接到URL的方法是跳过SSL验证(仅当我们确定连接时)
为此,您可以添加这个类并在onCreate方法中执行它
new NukeSSLCerts().nuke();
它将通过信任所有证书来跳过证书验证。