【问题标题】:Android Studio - SSLHandshakeException: Trust anchor for certification path not foundAndroid Studio - SSLHandshakeException:找不到证书路径的信任锚
【发布时间】:2022-01-23 05:16:44
【问题描述】:

我是 Java/PHP 编程的新手,我试图找到这个(可能很简单)修复的解决方案,但我没有找到。我已经查看了关于 SSL 问题的 Android 开发者文章 [https://developer.android.com/training/articles/security-ssl#CommonProblems] 但这似乎并没有解决我一直面临的任何问题到目前为止。

编辑:现在已经解决了,显然我忘记从“HTTPS”中删除“S”,这意味着它试图访问安全的 SSL 连接,而我显然没有。

错误还包括:

2022-01-23 15:56:27.925 413-1117/? E/audit: avc:  denied  { find } for pid=5704 uid=10342 name=tethering scontext=u:r:permissioncontroller_app:s0:c86,c257,c512,c768 tcontext=u:object_r:tethering_service:s0 tclass=service_manager permissive=0

并且在运行应用程序期间,完整的异常错误会显示为 toast 消息:

javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

我正在尝试通过 signup.java 访问https://192.168.0.159/LoginRegister/signup.php (localhost) 的 MySQL PHP。

我还尝试根据 Android 开发者文章将 android:networkSecurityConfig="@xml/network_security_config" along withandroid:usesCleartextTraffic="true" 添加到 Android Manifest 以及 raw 文件夹和 XML 文件夹中的 certificate.crt/network_security_config.xml。

我当前的 Android Gradle 插件版本是 7.0.4,我的 Gradle 版本是 7.2(我已经尝试更改两者的版本)。

如果您需要有关该项目的更多信息,请告诉我。

非常感谢,

布兰登。

【问题讨论】:

  • 使用自签名证书可能很麻烦。考虑从 DigiCert 等知名提供商处购买证书。

标签: java php android mysql


【解决方案1】:

正如您已经提到的,您没有 SSL 证书来访问 https,因为我假设您的 localhost ip 地址。

如果您已经在清单中使用android:usesCleartextTraffic="true",将https 更改为http 应该可以让事情顺利进行。

【讨论】:

  • 非常感谢您的回答!我没有意识到我怎么会忘记删除一个简单的“S”但我们到了。我会赞成你的回答,但我的声誉太低了。无论如何,非常感谢! :)
  • 布兰登没问题
猜你喜欢
  • 2021-03-18
  • 2017-01-08
  • 2019-02-24
  • 1970-01-01
  • 1970-01-01
  • 2017-05-06
  • 2020-04-25
  • 2018-01-06
相关资源
最近更新 更多