mobileconfig文件

經過Safari與mobileconfig獲取iOS設備UDIDhtml

UDID (Unique Device Identifier),惟一標示符,是iOS設備的一個惟一識別碼,每臺iOS設備都有一個獨一無二的編碼,UDID其實也是在設備量產的時候,生成隨機的UUID寫入到iOS設備硬件或者某一塊存儲器中,因此變成了固定的徹底不會改變的一個標識,用來區別每個惟一的iOS設備。node

隨着蘋果對程序內獲取UDID封殺的愈來愈嚴格,私有api已經獲取不到UDID,Mac地址等信息,繼而出現了使用鑰匙串配合uuid等等方法變相實現api

製做mobileconfig須要的文件:服務器

(1)mbaike.crt(https服務器端使用證書文件)
(2)mbaike.key(https服務器端使用證書對應的密鑰,其實就是一個txt文件)
(3)ca-bundle.pem(startssl官網下載的跟證書文件,具體的在哪裏下載,請在startssl控制面板中查找)
(4)unsigned.mobilecofig文件(IOS端生成的未簽名的配置描述文件) app

二、在mac上經過openssl命令生成簽名後的signed.mobileconfig文件:ui

openssl smime -sign -in unsigned.mobileconfig -out signed.mobileconfig -signer mbaike.crt -inkey mbaike.key -certfile ca-bundle.pem -outform der -nodetach

 

也能夠把key文件的密碼寫入到key文件中編碼

openssl rsa -in mbaike.key -out mbaikenopass.key

 

第二步的命令就應該是spa

openssl smime -sign -in unsigned.mobileconfig -out signed.mobileconfig -signer mbaike.crt -inkey mbaikenopass.key -certfile ca-bundle.pem -outform der -nodetach

 

這樣就完成了對mobileconfig的簽名工做了操作系統

pfx生成pemcode

openssl pkcs12 -in test.pfx -clcerts -nokeys -out cert.pem  可能須要密碼

pfx生成key

openssl pkcs12 -in test.pfx -nocerts -out cert.key

ca文件就是crt文件

 

使用原理:

1.在你的服務器上建立一個.mobileconfig的XML格式的描述文件;

 

2.服務器須要的數據,好比:UDID,IMEI須要在.mobileconfig描述文件中配置好,以及服務器接收數據的URL地址;

 

3.用戶在客戶端經過某個點擊操做完成.mobileconfig描述文件的安裝;

 

4.手機在安裝描述文件時,會向描述文件中配置好的URL發送UDID,IMEI等設備信息數據;

 

5.服務端收到設備信息數據後,經過scheme打開客戶端的app將設備信息做爲參數傳給客戶端;

 

6.客戶端在appDelegate裏面將 這個參數存到本地 ,而且存到鑰匙串,這樣即時app被卸載重裝,也無需再次安裝;

 

配置文件的信息:

<?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://127.0.0.1:6699/receive.do</string>
            <key>DeviceAttributes</key>
            <array>
                <string>SERIAL</string>
                <string>MAC_ADDRESS_EN0</string>
                <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>
        <key>PayloadIdentifier</key>
        <string>cn.com.aaaa</string>
        <key>PayloadDescription</key>
        <string>本文件僅用來獲取設備ID</string>
        <key>PayloadType</key>
        <string>Profile Service</string>
    </dict>
</plist>

 

其中,DeviceAttributes對應的key是你想要的信息,還能夠添加其餘信息,操做系統(iOS)安裝完描述文件,獲取完這些信息,會將這些信息進行編碼,傳值給你描述文件中的URL地址,這裏須要修改URL就好。

 

蘋果官方文檔介紹

相關文章
相關標籤/搜索