一. 搭建自己的服务器
本人使用docker镜像(不知安全与否):
docker pull richarvey/nginx-php-fpm:php7
二. 创建容器并配置ssl相关
配置ssl过程
- 到阿里云下载ssl相关文件
- 将ssl拷贝进服务器文件中
docker cp c0eed2195cfe:/etc/nginx/sites-available/default.conf sh/
- 进入容器,创建cert文件夹
$ docker exec -it c0eed2195cfe /bin/bash
$ cd /etc/nginx/
$ mkdir cert
$ exit
$ docker cp ssl2/ssl.key c0eed2195cfe:/etc/nginx/cert/
$ docker cp ssl2/ssl.pem c0eed2195cfe:/etc/nginx/cert/
- 拷贝出配置文件
$ docker cp c0eed2195cfe:/etc/nginx/sites-available/default.conf sh/
- 将配置文件下载到本地,然后进行相关配置
server {
listen 443; ## listen for ipv4; this line is default and implied
listen [::]:443 default ipv6only=on; ## listen for ipv6
ssl on;
# ssl证书地址
ssl_certificate /etc/nginx/cert/ssl.pem; # pem文件的路径
ssl_certificate_key /etc/nginx/cert/ssl.key; # key文件的路径
# ssl验证相关配置
ssl_session_timeout 5m; #缓存有效期
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #加密算法
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #安全链接可选的加密协议
ssl_prefer_server_ciphers on; #使用服务器端的首选算法
root /var/www/html;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name _;
# Disable sendfile as per https://docs.vagrantup.com/v2/synced-folders/virtualbox.html
sendfile off;
# Add stdout logging
error_log /dev/stdout info;
access_log /dev/stdout;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.html
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
location = /404.html {
root /var/www/errors;
internal;
}
location ^~ /ngd-style.css {
alias /var/www/errors/style.css;
access_log off;
}
location ^~ /ngd-sad.svg {
alias /var/www/errors/sad.svg;
access_log off;
}
# pass the PHP scripts to FastCGI server listening on socket
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
}
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
expires 5d;
}
# deny access to . files, for security
#
location ~ /\. {
log_not_found off;
deny all;
}
location ^~ /.well-known {
allow all;
auth_basic off;
}
}
- 再次将配置文件提交
- 将配置文件放进docker容器中
$ docker cp sh/ssl.conf
$ c0eed2195cfe:/etc/nginx/sites-enabled/
- 在容器内进行测试
$ nginx -t
- 容器内重启
$ nginx -s reload
三. 配置UDID相关
- 创建
.mobileconfig
文件并进行签名
<!--参考:https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/iPhoneOTAConfiguration/ConfigurationProfileExamples/ConfigurationProfileExamples.html-->
<?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>https://www.yoururl.com/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>dev.skyfox.org</string> <!--组织名称-->
<key>PayloadDisplayName</key>
<string>查询设备UDID</string> <!--安装时显示的标题-->
<key>PayloadVersion</key>
<integer>1</integer>
<key>PayloadUUID</key>
<string>3C4DC7D2-E475-3375-489C-0BB8D737A653</string> <!--自己随机填写的唯一字符串,http://www.guidgen.com/ 可以生成-->
<key>PayloadIdentifier</key>
<string>dev.skyfox.profile-service</string>
<key>PayloadDescription</key>
<string>本文件仅用来获取设备ID</string> <!--描述-->
<key>PayloadType</key>
<string>Profile Service</string>
</dict>
</plist>
- 将
.mobileconfig
文件签名
# 终端查找电脑可用于签名的证书
$ /usr/bin/security find-identity -p codesigning -v
# 使用证书进行签名
$ /usr/bin/security cms -S -N "iPhone Distribution: yourCertificates" -i udid_unsigned.mobileconfig -o udid.mobileconfig
-
将签名的
.mobileconfig
文件放在oss,并设置格式为application/x-apple-aspen-config
-
创建index.php文件
<?php
$UDID = $_GET['UDID'] ? $_GET['UDID'] : $_POST['UDID'];
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no" name="viewport" id="viewport" />
<script src="clipboard.min.js"></script>
<title>获取您的UDID</title>
<style type="text/css">
body {
margin: 0;
padding: 0;
color: #333;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 14px;
line-height: 1.42857;
}
#content {
width: 96%;
padding: 0px 0;
margin: 0 auto;
text-align: center;
}
#left {
width:96%;
padding:20;
margin:20;
text-align:left;
}
#header{
background-color: #1aa79a;
height: 120px;
margin: 0;
padding: 0;
color: white;
font-size: 50px;
padding-top: 40px;
text-align: center;
}
#showText{
font-size: 18px;
width: 100%;
padding:0;
height:40px;
/* text-align: center; */
}
.udid-intro {
color: #8c9293;
line-height: 24px;
}
#footer{
border-top: 1px solid #979797;
font-family: "Roboto Slab","Helvetica Neue",Helvetica,"Hiragino Sans GB",Arial,sans-serif;
margin-top: 50px;
padding-bottom: 70px;
padding-top: 30px;
text-align: center;
}
.buttons{
background: #1AA79A none repeat scroll 0 0;
border: 1px solid #777;
border-radius: 8px;
box-shadow: 0 -1px 3px rgba(255, 255, 255, 0.5) inset, 0 2px 2px rgba(0, 0, 0, 0.2);
color: #fff;
cursor: pointer;
font-family: "Microsoft Yahei",Arial,Tahoma,sans-serif;
font-size: 14px;
font-style: normal;
font-weight: bold;
padding: 8px 12px;
margin-left:10px;
text-decoration: none;
text-shadow: -1px -1px rgba(0, 0, 0, 0.1), 0 0 15px rgba(255, 255, 255, 0.75);
text-transform: none;
white-space: nowrap;
}
</style>
</head>
<body>
<div id="header">
UDID
</div>
<div id="content">
<br><br>
<input name="" id="showText" placeholder="点击获取UDID即可获取" value="<?php echo $UDID;?>" />
<br><br>
<a class="buttons" href="https://youurl.com/udid.mobileconfig" target="_blank">获取UDID</a>
<a class="buttons" id="copyButton" data-clipboard-target="#showText">拷贝UDID</a>
<br><br>
</div>
<div id="left">
<p class="udid-intro">UDID 是一种 iOS 设备的特殊识别码。除序号之外,每台 iOS 装置都另有一组独一无二的号码,我们就称之为识别码( Unique Device Identifier, UDID )。就像我们的身份证一样。开发者需要知道你的 UDID,才可以让你的手机安装访问测试中的应用,就像需要你的身份证才可以让你登机一样。
<br>
操作步骤:<br>
1. 确认您的设备为苹果手机;<br>
2. 点击获取UDID按钮;<br>
3. 安装描述文件;<br>
4. 前往手机设置页;<br>
5. 点击已下载描述文件;<br>
6. 安装描述文件;<br>
7. 将获取的UDID复制给开发人员;<br>
8. 开发人员将UDID添加到打包文件中从新打包应用;<br>
9. 确认开发人员打了新的应用包后扫描下方第一个二维码下载应用;<br>
</p>
</div>
<div id="content">
<br>
<img src="qr.png" width ="200">
</div>
<div id="footer">
@UDID
</div>
</body>
<script type="text/javascript">
//init
var clipboard = new ClipboardJS('#copyButton');
//优雅降级:safari 版本号>=10,提示复制成功;否则提示需在文字选中后,手动选择“拷贝”进行复制
clipboard.on('success', function(e) {
alert('复制成功!')
e.clearSelection();
});
clipboard.on('error', function(e) {
alert('请选择“拷贝”进行复制!')
});
</script>
</html>
- 创建recive.php文件
<?php
$data = file_get_contents('php://input');
$plistBegin = '<?xml version="1.0"';
$plistEnd = '</plist>';
$pos1 = strpos($data, $plistBegin);
$pos2 = strpos($data, $plistEnd);
$data2 = substr ($data,$pos1,$pos2-$pos1);
$xml = xml_parser_create();
xml_parse_into_struct($xml, $data2, $vs);
xml_parser_free($xml);
$UDID = "";
$CHALLENGE = "";
$DEVICE_NAME = "";
$DEVICE_PRODUCT = "";
$DEVICE_VERSION = "";
$iterator = 0;
$arrayCleaned = array();
foreach($vs as $v){
if($v['level'] == 3 && $v['type'] == 'complete'){
$arrayCleaned[]= $v;
}
$iterator++;
}
$data = "";
$iterator = 0;
foreach($arrayCleaned as $elem){
$data .= "\n==".$elem['tag']." -> ".$elem['value']."<br/>";
switch ($elem['value']) {
case "CHALLENGE":
$CHALLENGE = $arrayCleaned[$iterator+1]['value'];
break;
case "DEVICE_NAME":
$DEVICE_NAME = $arrayCleaned[$iterator+1]['value'];
break;
case "PRODUCT":
$DEVICE_PRODUCT = $arrayCleaned[$iterator+1]['value'];
break;
case "UDID":
$UDID = $arrayCleaned[$iterator+1]['value'];
break;
case "VERSION":
$DEVICE_VERSION = $arrayCleaned[$iterator+1]['value'];
break;
}
$iterator++;
}
$params = "UDID=".$UDID."&CHALLENGE=".$CHALLENGE."&DEVICE_NAME=".$DEVICE_NAME."&DEVICE_PR ODUCT=".$DEVICE_PRODUCT."&DEVICE_VERSION=".$DEVICE_VERSION;
//header("Location: http://dev.skyfox.org/udid?data=".rawurlencode($params));
header('HTTP/1.1 301 Moved Permanently');
header("Location: https://www.yoururl.com/index.php&".$params);
?>
将上述文件提交到https服务器,即可正常获取手机UDID。
参考链接:https://github.com/shaojiankui/iOS-UDID-Safari