自建Tomcat完成Android App Links实践

搭建Tomcat服务器(支持SSL)

申请外网域名

使用nat123获得(外网映射tomcat本地网)

为域名申请阿里SSL证书

申请流程
此处域名验证方式使用文件验证
拿到pfx文件后接下步骤

修改conf/server.xml

http默认80端口,https默认443端口,App Links需要使用https
修改原端口8080为80,8443为443

certificateKeystoreFile为ssl证书文件保存地址
certificateKeystorePassword为ssl证书密码

    <Connector port="80" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="443" />
	
	<Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol"
            maxThreads="150" SSLEnabled="true">
        <SSLHostConfig>
                <Certificate certificateKeystoreFile="D:\xxx\apache-tomcat-xxx\conf\cert\xxx.pfx"
                        certificateKeystoreType="PKCS12" 
                        certificateKeystorePassword="z4NY3u6u"/>
        </SSLHostConfig>
    </Connector>
修改conf/web.xml

添加如下代码可以使http请求自动跳https请求

<login-config>  
    <!-- Authorization setting for SSL -->  
    <auth-method>CLIENT-CERT</auth-method>  
    <realm-name>Client Cert Users-only Area</realm-name>  
</login-config>  
<security-constraint>  
    <!-- Authorization setting for SSL -->  
    <web-resource-collection >  
        <web-resource-name >SSL</web-resource-name>  
        <url-pattern>/*</url-pattern>  
    </web-resource-collection>  
    <user-data-constraint>  
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>  
    </user-data-constraint>  
</security-constraint>

按照androidstudio AppLinks Assist指引配置

其中一步将assetlinks.json文件放进webapps/.well-known文件夹下

需要cmd使用rm命令创建.well-known文件夹

真机验证

使用网址直接打开应用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

萌面小侠Plus

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值