问题描述
我在AndroidManifest.xml
中定义我的应用程序链接:
I define my app links as follows in 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监视器控制台中所示:
The app correctly detects URLs from the host correctly but prompts if the user would like to open them in the application or the browser because verification fails as seen in the Android monitor console:
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
My assetlinks.json file is located at mysite.com/.well-known/assetlinks.json
and contains the correct package name and SHA256 hash. It is also accessible via http and https. I have verified the SHA hash matches that from the keystore by extracting the CERT.RSA file from the APK and using keytool -printcert -file CERT.RSA
我已经尝试调用https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://domain1:port&relation=delegate_permission/common.handle_all_urls
以及使用 Google网站声明List Tester 都返回OK.
I have tried calling https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://domain1:port&relation=delegate_permission/common.handle_all_urls
as well as using the google site Statement List Tester and both return OK.
我正在使用运行Android 7的Nexus设备进行测试.
I am using a Nexus device running Android 7 for testing.
根据文档,我已经完成了应用所需的一切与工作联系.还有什么我可以检查的吗?
According to the documentation I have done everything required for app linking to work. Is there anything else that I can check?
我的服务器在Windows 7上运行IIS,我已经在IIS和web.config文件中添加了application/json作为模仿类型.会因为我使用自签名SSL证书而失败吗?
My server is running IIS on Windows 7, I have already added application/json as a mimetype in the IIS and web.config files. Could it be failing because I am using a self-signed SSL certificate?
SingleHostAsyncVerifier也记录验证失败. (将mysite替换为示例和SHA哈希)
SingleHostAsyncVerifier also logs the verification failing. (replaced mysite with example and SHA hash)
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.
推荐答案
尽管应用程序链接文档中未提及,但应用程序链接要求服务器具有来自公共或可信证书颁发机构的有效SSL证书.自签名证书不起作用.
Although unmentioned in the app links documentation, app links require that the server have a valid SSL certificate from a public or trusted certificate authority. Self-signed certificates do not work.
切换到 https://www.thawte.com/发出的SSL证书后链接验证成功完成.
After switching to a SSL certificate issued by https://www.thawte.com/ the app link verification completes successfully.
这篇关于Android M App链接验证失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!