超级签具体实现

签名原理

使用了苹果提供给开发者的Ad-Hoc分发通道,把安装设备当做开发设备进行分发。

优势:
直接分发,安装即可运行
稳定,不会有证书吊销导致的风险

缺点:
单开发者账号的iPhone设备数量只有100个

整体架构

  1. 设备安装描述文件后,会向服务器发送设备的UDID。
  2. 服务器收到UDID后,将UDID注册到某个开发者账号下。
  3. 再生成签名用的描述文件,给IPA签名。
  4. 然后iPA传Server,使用itms-services方式让用户下载。

技术实现

一、使用配置文件获取UDID
  1. 在你的Web服务器上创建一个.mobileconfig的描述文件;
  2. 用户点击完成.mobileconfig描述文件的安装;
  3. 服务器需要的数据,比如:UDID,需要在.mobileconfig描述文件中配置好,以及服务器接收数据的URL地址;
  4. 当用户设备安装描述文件后,设备会回调你设置的URL
    注:.mobileconfig的demo如下:
    <?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>PayloadContent</key>
         <dict>
             <key>URL</key>
             <string>http://192.168.1.40/data/receive.php</string> <!--接收数据的接口地址-->
             <key>DeviceAttributes</key>
             <array>
                 <string>UDID</string>
                 <string>IMEI</string>
                 <string>ICCID</string>
                 <string>VERSION</string>
                 <string>PRODUCT</string>
             </array>
         </dict>
         <key>PayloadOrganization</key>
         <string>com.sssss.orgName</string>  <!--组织名称-->
         <key>PayloadDisplayName</key>
         <string>获取设备UDID</string>  <!--安装时显示的标题-->
         <key>PayloadVersion</key>
         <integer>1</integer>
         <key>PayloadUUID</key>
         <string>3C4DC7D2-E475-3375-489C-0BB8D737A653</string>  <!--随机填写的字符串-->
         <key>PayloadIdentifier</key>
         <string>dev.skyfox.profile-service</string>
         <key>PayloadDescription</key>
         <string>获取设备UDID</string>   <!--描述-->
         <key>PayloadType</key>
         <string>Profile Service</string>
     </dict>
    </plist>
    注意:mobileconfig下载时设置文件内容类型Content Type为:application/x-apple-aspen-config
    HTTPS服务器上的文件
    当访问mobileconfig文件不能直接下载时,可能就需要设置mime content type了,application/x-apple-aspen-config,
    设置content type大体上两种方法
    .htaccess增加如下配置
<IfModule mod_mime.c>
     AddType application/x-apple-aspen-config .mobileconfig
</IfModule>


php等动态语言直接设置

//读取文件流为$mobileconfig
header('Content-type: application/x-apple-aspen-config; chatset=utf-8');
header('Content-Disposition: attachment; filename="test.mobileconfig"');
echo $mobileconfig;
服务器接收返回数据并显示

设置好mobileconfig文件中的URL,并且下载安装mobileconfig之后,iOS设备会POST XML数据流给你的mobileconfig文件,PayloadContent节点中设置的URL。以下是返回数据的格式

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
   <dict>
     <key>IMEI</key>
     <string>*********</string>
     <key>PRODUCT</key>
     <string>iPhone7,1</string>
     <key>UDID</key>
     <string>*************</string>
     <key>VERSION</key>
     <string>15B206</string>
   </dict>
 </plist>

receive.php

<?php
$data = file_get_contents('php://input');
//这里可以进行xml解析
header('HTTP/1.1 301 Moved Permanently');  //这里一定要301跳转,否则设备安装会提示"无效的描述文件"
header("Location: http://192.168.1.40/udid.php?".$params);
?>

index.php

<?php
$UDID =  $_GET['UDID'] ? $_GET['UDID'] : $_POST['UDID'];
?>
UDID:<input style="width:300px;" name="" value="<?php echo $UDID;?>" />

值得注意的是重定向一定要使用301重定向,有些重定向默认是302重定向,这样就会导致安装失败,设备安装会提示”无效的描述文件

获取UDID第三方库

Apple Developer Center 自动化工具

接下来的就是在获取到用户的UDID之后,注册新的开发者设备+更新Provisioning Profile。 这里需要借助开源工具:Spaceship

Apple Developer Center

添加设备命令:

Spaceship::Portal.device.create!(name: "Private iPhone 6", udid: "32123898...")

下载描述文件:

profiles_appstore_adhoc = Spaceship::Portal.provisioning_profile.ad_hoc.all
File.write("NFname.mobileprovision", profile.download)

 

自动签名

推荐使用 Sigh 这个框架(只能mac环境), 还可以使用开心命令行签名工具,利用p12证书来实现在linux服务器上也能重签名。

自动签名封包工具

分发已签名的应用

可参照部署企业包的方式

转载于:https://www.cnblogs.com/Zhuyao/p/11435461.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值