【问题标题】:Trust anchor for certification path not found error with AeroGear PushPlugin and cordova android platformAeroGear PushPlugin 和 cordova android 平台未找到证书路径的信任锚
【发布时间】:2017-11-09 23:43:55
【问题描述】:

我正在使用 cordovaAeroGear PushPlugin 创建一个 android 应用程序,它使用 https 与统一通信推送服务器。我在我的服务器中使用有效的 CA 认证支持 (TLS1.2)。

使用cordova run android 执行时,在我的设备中返回此错误:

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

知道了,我将证书添加到:

platforms/android/res/raw/myCert.crt

而config.xml中的这个标签:

  <platform name="android">
    <network-security-config>
        <base-config cleartextTrafficPermitted="true">
            <trust-anchors>
                <certificates src="myCert.crt" />
            </trust-anchors>
        </base-config>
    </network-security-config>
    </platform>

我遵循了几种建议的解决方案,但不适用于我的情况。

感谢您的帮助。

【问题讨论】:

  • 没有建议!!
  • 您正在测试哪个 Android 版本?如果是 5.0 或更高版本,您使用的是哪个 webview 版本?由于错误,某些版本无法与受信任的证书连接,但应在最新的 webview 上修复。我不确定您通过将其添加到 config.xml 来尝试实现什么,但这对您的应用没有任何作用。
  • 我使用 android 6.0.0,我使用了以下链接中的文档:developer.android.com/training/articles/…
  • 当你使用android 6时,你能检查你的webview版本吗? (设置 -> 应用程序 -> Android 系统 WebView)。该链接讨论 res/xml/network_security_config.xml 文件,这与 Cordova 的 config.xml 不同,您需要一个资源文件标签或一个挂钩来创建该文件。
  • 问题出在我的 UPS 服务器的 CA 中 :) 寻求帮助

标签: android cordova push-notification ssl-certificate aerogear


【解决方案1】:

这是 UPS Widfly 服务器的证书生成问题。

如果您拥有由 trsut 提供商提供的证书颁发机构 CA

按照以下步骤操作:

1- 您必须首先使用以下命令将您的提供商提供的 PEM 证书转换为 p12:

$ openssl pkcs12 -export -out yourCertificategenerate.p12 -inkey yourCertificatekey.key  -in certifacteDelivedFromProvider.pem -certfile yourCertificateFromProvider.pem // file contains -----BEGIN CERTIFICATE----- ... -----END CERTIFICATE-----)

2- 使用此命令创建本地密钥库(yourCertificategenerate.jks),并使用此命令将其复制到独立/配置目录:

$ keytool -importkeystore -deststorepass yourpassword -destkeypass yourpassword -destkeystore yourNewCertificateGenerate.jks -srckeystore yourCertificateGenerate.p12 -srcstoretype PKCS12 -srcstorepass ""

检查认证链

openssl s_client -connect yourDomaine.com -debug

如果一切正常,你应该有这样的东西:

【讨论】:

    猜你喜欢
    • 2019-01-02
    • 2022-01-06
    • 2017-01-08
    • 2019-02-24
    • 1970-01-01
    • 1970-01-01
    • 2020-04-25
    • 2020-11-08
    相关资源
    最近更新 更多