Android M 应用链接验证失败

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

我在 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 哈希与 keystore 中的匹配

我尝试调用 https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://domain1:port&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.

最佳答案

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

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

关于Android M 应用链接验证失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41708549/

相关文章:

android - 为什么Android应用程序无法在Intellij IDEA中构建?

ajax - Facebook 聊天如何避免连续轮询服务器?

android - 从 Byte 扩展到 Int(Marshmallow 错误)

java - hibernate :HTTP Status 500 - Internal Server Error

javascript - 使用.getJSON在本地提取JSON数据但数据不会出现

Android - 指纹登记

android - 如何处理在 Android M 中删除广播接收器的权限?

java - 在 Android 中循环访问多个 JSON 对象

Android:启动共享 Intent 会关闭我的 Activity

android - AVD 设置中缺少“快照”和 'Use Host GPU' 选项