JAVA和Nginx 教程大全

网站首页 > 精选教程 正文

设置OTA无线安装 ipa

wys521 2024-09-14 13:43:57 精选教程 33 ℃ 0 评论

概述

一、OTA是什么?

OTA就是Over-the-Air,是苹果为了使开发者能够通过无线方式分发自己内部的应用而提供的一种技术。

通过OTA的方式安装,开发者只需在移动设备上访问指定的Url即可进行下载安装,不必再依赖数据线。

二、架设OTA需要什么?

需要备注Web服务器可以直接使用Mac上的Apache或者下载配置NginxSSL证书用来开启HTTPS服务HTTPS服务根据苹果官方文档,对于iOS 7.1及以系统必须使用HTTPSHTML页面用来下载安装包的页面IPA有个人开发者或者企业签名的IPA包manifest.plistIPA对应的清单文件icon57*57和512*512的图片

部署

一、Web服务器部署

Mac自带Apache(也可以使用nginx),我们可以直接进行用httpd -v查看apache的版本号

$ httpd -v
Server version: Apache/2.4.34 (Unix)
Server built: Feb 22 2019 19:30:04

Apache的常用命令:

  • 启动:sudo apachectl start
  • 停止:sudo apachectl stop
  • 重启:sudo apachectl restart

启动Apache后在浏览器中输入http://localhost或者http://127.0.0.1,看到“It Works”页面即开启成功


Mac上Apache的文件目录默认在/Library/WebServer/Documents,可以通过/etc/apache2/httpd.conf进行修改


二、获得SSL签名证书

这里我们使用自签名的方式,有条件的话可以付费选择苹果认证的签名

  • 创建存储证书的路径
$ cd /private/etc/apache2/
$ sudo mkdir ssl
$ cd ssl
  • 创建主机秘钥
$ sudo openssl genrsa -out ip211.key 2048
Generating RSA private key, 2048 bit long modulus
...............................................................................................................+++
.......................................................+++
e is 65537 (0x10001)
  • 创建签署申请
$ sudo openssl req -new -key ip211.key -out ip211.csr

注意Comon Name处一定要填写完整的域名或者IP地址,其他可以随意填写或留空

You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) []:cn
State or Province Name (full name) []:
Locality Name (eg, city) []:
Organization Name (eg, company) []:
Organizational Unit Name (eg, section) []:
Common Name (eg, fully qualified host name) []:10.6.60.211
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
  • 创建SSL证书
    -days 参数后面是证书有效期,根据自己需求更改
$ sudo openssl x509 -req -days 3650 -in ip211.csr -signkey ip211.key -out ip211.crt

Signature ok
subject=/C=cn/CN=10.6.60.211
Getting Private key
  • 移除秘钥的密码
$ sudo openssl rsa -in ip211.key -out ip211-nopass.key

writing RSA key

操作完毕后我们应该有以下几个文件

$ ls -l
total 32
-rw-r--r-- 1 root wheel 1679 May 9 17:01 ip211-nopass.key
-rw-r--r-- 1 root wheel 1017 May 9 16:44 ip211.crt
-rw-r--r-- 1 root wheel 911 May 9 16:37 ip211.csr
-rw-r--r-- 1 root wheel 1679 May 9 16:35 ip211.key

三、配置HTTPS服务

1 备份要修改的文件

$ sudo cp /private/etc/apache2/httpd.conf /private/etc/apache2/httpd.conf.bak 
$ sudo cp /private/etc/apache2/extra/httpd-ssl.conf /private/etc/apache2/extra/httpd-ssl.conf.bak 
$ sudo cp /private/etc/apache2/mime.types /private/etc/apache2/mime.types.bak 

2 修改配置文件/private/etc/apache2/httpd.conf (只读文件,请用管理员权限打开以便修改,如:sudo vim /private/etc/apache2/httpd.conf)
(1) 加载Apache中与HTTPS相关的模块,去掉以下两个模块的注释

LoadModule socache_shmcb_module libexec/apache2/mod_socache_shmcb.so
LoadModule ssl_module libexec/apache2/mod_ssl.so

(2) 加载Apache中与HTTPS相关的配置,去掉以下配置的注释

Include /private/etc/apache2/extra/httpd-ssl.conf

3 修改配置文件/private/etc/apache2/extra/httpd-ssl.conf (只读文件,请用管理员权限打开以便修改,同上)
修改以下三处:
(1)ServerName,主机名,改为本机的IP

ServerName 10.6.60.211

(2) SSLCertificateFile,证书路径,改为SSL证书存放路径

SSLCertificateFile "/private/etc/apache2/ssl/ip211.crt"

(3) SSLCertificateKeyFile,秘钥路径,改为SSL未加密秘钥存放路径

SSLCertificateKeyFile "/private/etc/apache2/ssl/ip211-nopass.key"

4 设定服务器MME类型
根据苹果官方文档,需要将ipa和plist加入服务器的MME类型
修改/private/etc/apache2/mime.types,加入以下两条

application/octet-stream ipa
text/xml plist

5 检测Apache配置文件并重启Apache

$ sudo apachectl -t

可能会报错

AH00557: httpd: apr_sockaddr_info_get() failed for bogon
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK

可以修改/private/etc/apache2/httpd.conf,将ServerName的注释取消,再次检测

$ sudo apachectl -t
Syntax OK

其他报错自行查找解决,无报错后重启Apache

sudo apachectl restart

在浏览器输入https://即可访问


四、准备ipa和对应的manifest.plist

1 在Web服务器的文件目录下创建对应的文件夹
进入Apache Web服务器的文件根目录/Library/WebServer/Documents,创建包的存放路径,icon存放路径,SSL证书存放路径

$ sudo mkdir testapp
$ cd testapp
$ sudo mkdir ipa
$ sudo mkdir icon
$ sudo mkdir ssl
$ sudo mkdir plist
  • 生成的ipa放入testapp文件夹下
  • 57/*57和512/*512的icon放入icon文件夹下
  • manifest.plist放入plist文件夹下
  • 生成的crt文件放入ssl文件夹下
sudo cp /private/etc/apache2/ssl/ip211.crt /Library/WebServer/Documents/testapp/ssl/ip211.crt

2 生成manifest.plist文件_(也可以跳过此步奏直接修改现成manifest.list模版)

  • Mac上打包的步骤不再详述,在Archive时,将Include manifest for over-the-air installation选项勾上
  • 依次填入内容
Name:【包的显示名字】
App URL:【https://主机地址/testapp/ipa/xxx.ipa】
Display Image URL:【https://主机地址/testapp/icon/52.png】
Full Size Image URL:【https://主机地址/testapp/icon/512.png】
  • 最后在生成的ipa目录下会同时生成一个manifest.plist文件 3 修改manifest.plist模版
    manifest.plist如下(【】内是需要修改的内容,正式内容不包括【】)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
 <key>items</key>
 <array>
 <dict>
 <key>assets</key>
 <array>
 <dict>
 <key>kind</key>
 <string>software-package</string>
 <key>url</key>
 <string>【https://主机地址/testapp/ipa/xxx.ipa】</string>
 </dict>
 <dict>
 <key>kind</key>
 <string>display-image</string>
 <key>url</key>
 <string>【https://主机地址/testapp/icon/52.png】</string>
 </dict>
 <dict>
 <key>kind</key>
 <string>full-size-image</string>
 <key>url</key>
 <string>【https://主机地址/testapp/icon/512.png】</string>
 </dict>
 </array>
 <key>metadata</key>
 <dict>
 <key>bundle-identifier</key>
 <string>【Bundle ID】</string>
 <key>bundle-version</key>
 <string>【版本号】</string>
 <key>kind</key>
 <string>software</string>
 <key>title</key>
 <string>【包的显示名字】</string>
 </dict>
 </dict>
 </array>
</dict>
</plist>

需要修改和确认的字段说明

字段说明software-package应用 (.ipa) 文件的完全限定 HTTPS URLdisplay-image57 x 57 像素的 PNG 图像,在下载和安装过程中显示。指定图像的完全限定 URLfull-size-image512 x 512 像素的 PNG 图像,表示 iTunes 中相应的应用bundle-identifier应用的包标识符,com.xx.xxxbundle-version应用的包版本,0.1.0title下载和安装过程中显示的应用的名称

修改完毕后,将manifest.plist放入/Library/WebServer/Documents/testapp/plist目录下

五、制作下载所用Web页面

OTA是通过 WebKit 解析链接中的itms-services://来实现的,因此我们需要做超链接

<a href="itms-services://?action=download-manifest&url=【https://example.com/manifest.plist】">Install App</a>

另外需要在手机上安装签名证书,因此需要给证书也做一个超链,完整HTML如下:

<!DOCTYPE html>
<html>
 <head>
 <meta charset="utf-8" mime-types="text/plain">
 <title></title>
 </head>
 <body>
 <a style="display:block" href="itms-services://?action=download-manifest&url=【https://主机地址/testapp/plist/manifest.plist】">下载ipa</a>
 <a style="display:block" href="【https://主机地址/testapp/ssl/ip211.crt】">下载证书</a>
 </body>
</html>

存为index.html,放入/Library/WebServer/Documents/testapp/下

六、下载安装

在iPhone上用Sarfri浏览器,访问https://主机地址/testapp/即可看到


点击下载证书,下载安装配置文件
在设置-通用-描述文件与设备管理中,选择已下载的配置文件,进行安装


安装时会提示:只有在“证书信任设置”中启用,网站才会信任此证书。


这是在iOS 10中,苹果加入的认证,因此还需在设置-通用-关于本机-证书信任设置中将完全信任打开


再返回Sarfri浏览器,点击“下载ipa”,即可下载安装

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表