【问题标题】:SSLHandshakeException when connecting through internet通过 Internet 连接时出现 SSLHandshakeException
【发布时间】:2018-03-30 09:52:17
【问题描述】:

在我的 android 应用程序中,我可以毫无问题地使用本地 wifi 连接到此 url:

https://didgahmobile.chargoon.net/

但是,当我尝试通过互联网连接时,例如使用移动数据或通过代理连接时,我在 android 应用程序中收到 SSLHandshakeException。桌面和移动 chrome 浏览器也会显示消息 "Your connection is not private"

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

我检查了服务器防火墙,没有IP地址限制。

我的另一个https url 地址也有一点不同的情况。在这种情况下,我第一次通过本地 wifi 连接后,我可以通过代理或移动数据连接,但在全新安装或清除数据后使用移动数据或代理连接会抛出相同的SSLHandshakeException

那么问题出在哪里?

【问题讨论】:

    标签: android https proxy ssl-certificate android-volley


    【解决方案1】:

    如果您使用的是 android 7,请勾选此项,因为您必须添加一些配置:

    <network-security-config>  
          <domain-config>  
               <domain includeSubdomains="true">yourDomain.com</domain> 
                                 <!-- like: didgahmobile.chargoon.net -->  
               <trust-anchors>  
                      <!-- Trust preinstalled CAs -->  
                      <certificates src="system" />  
                      <!-- Additionally trust user added CAs -->  
                      <certificates src="user" />  
               </trust-anchors>  
          </domain-config>  
     </network-security-config>
    
    <application
            android:name="yourappname"
            ...
            android:networkSecurityConfig="@xml/network_security_config">
    

    来源:Trusted certificates

    【讨论】:

    • 所有安卓版本都有这个问题。但是我使用了这个解决方案,它并没有解决 android 8 及更早版本的问题。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2012-04-16
    • 2023-03-03
    • 2017-10-24
    • 1970-01-01
    • 1970-01-01
    • 2015-06-05
    • 2018-08-03
    • 1970-01-01
    相关资源
    最近更新 更多