【问题标题】:Android M App Link Verification failsAndroid M 应用链接验证失败
【发布时间】:2017-01-17 22:58:51
【问题描述】:

我在AndroidManifest.xml中定义我的应用链接如下:

<intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <category android:name="android.intent.category.DEFAULT"/>

    <data android:host="mysite.com" android:scheme="http"/>
    <data android:host="mysite.com" android:scheme="https"/>
    <data android:host="www.mysite.com" android:scheme="http"/>
    <data android:host="www.mysite.com" android:scheme="https"/>
</intent-filter>

应用程序正确检测到来自主机的 URL,但提示用户是否希望在应用程序或浏览器中打开它们,因为验证失败,如 Android 监控控制台所示:

01-17 15:44:28.847 7084-30015/? I/IntentFilterIntentSvc: Verifying IntentFilter. verificationId:2 scheme:"https" hosts:"mysite.com www.mysite.com" package:"com.site.myapp.android.flavor".
01-17 15:44:29.821 7084-30015/? I/IntentFilterIntentSvc: Verification 2 complete. Success:false. Failed hosts:mysite.com,www.mysite.com.

我的assetlinks.json 文件位于mysite.com/.well-known/assetlinks.json,包含正确的包名和SHA256 哈希。它也可以通过 http 和 https 访问。我通过从 APK 中提取 CERT.RSA 文件并使用 keytool -printcert -file CERT.RSA

验证了 SHA 哈希与密钥库中的匹配

我曾尝试调用https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://domain1:port&amp;relation=delegate_permission/common.handle_all_urls 以及使用google site Statement List Tester 并且都返回OK。

我正在使用运行 Android 7 的 Nexus 设备进行测试。

根据the documentation,我已经完成了应用链接工作所需的一切。还有什么我可以检查的吗?

我的服务器在 Windows 7 上运行 IIS,我已经在 IIS 和 web.config 文件中添加了 application/json 作为 mimetype。会不会因为我使用的是自签名 SSL 证书而失败?

编辑:SingleHostAsyncVerifier 还会记录验证失败。 (将 mysite 替换为示例和 SHA 哈希)

01-17 15:44:29.817 7084-30017/? I/SingleHostAsyncVerifier: Verification result: checking for a statement with source a <
a: "https://www.example.com"
>
, relation delegate_permission/common.handle_all_urls, and target b <
a: "com.mypackage.flavor"
b <
a: "(SHA256 hash)"
>
>
--> false.
01-17 15:44:29.820 7084-30016/? I/SingleHostAsyncVerifier: Verification result: checking for a statement with source a <
a: "https://example.com"
>
, relation delegate_permission/common.handle_all_urls, and target b <
a: "com.mypackage.flavor"
b <
a: "(SHA256 hash)"
>
>
--> false.

【问题讨论】:

  • 用这个标签检查logcat:SingleHostAsyncVerifier
  • @SimonMarquis 我刚刚将它添加到原始问题中。它还显示验证失败。
  • 确实很奇怪。快速检查:你确定 sha 匹配吗? (调试版本与发布版本),提供的文件是否为application/json,它的 json 是否有效?
  • 更奇怪的是,它声明了 2 个验证,但您设置了 4 个。您是否已经尝试过一个。
  • 我刚刚向 Postman 确认了它是作为 application/json 而不是 text/html 提供的。我认为只有 2 次验证的原因是它尝试仅通过 https 验证 site.com 和 www.site.com。我只尝试了一个声明,但仍然失败。我刚刚验证了在 project/build/outputs/apk 中生成的 apk 中的 SHA 也与 assetslinks.json 文件中的相匹配。

标签: android json android-6.0-marshmallow deep-linking applinks


【解决方案1】:

虽然应用链接文档中未提及,但应用链接要求服务器具有来自公共或受信任证书颁发机构的有效 SSL 证书。自签名证书不起作用。

切换到https://www.thawte.com/颁发的SSL证书后,应用链接验证成功完成。

【讨论】:

    猜你喜欢
    • 2017-05-20
    • 2020-12-15
    • 1970-01-01
    • 2019-01-30
    • 2014-05-24
    • 1970-01-01
    • 2016-01-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多