2012-03-01 63 views
3

如何將.p12文件插入到.mobileconfig文件中?將pkcs12插入到mobileconfig文件

Apple配置實用程序當前在.p12文件中執行一些未知的轉換/編碼,同時將其插入.mobileconfig(它只是一個xml文件)。

我想通過直接創建xml文件而不使用Apple iPhone配置實用程序來創建此.mobileconfig文件。

感謝, Elison

回答

1

如果要插入你只需要選擇所選擇的配置文件的iPhone配置實用程序中的憑據選項卡中的iPhone配置文件中的.p12文件。當你configure它將ask for the .p12 file附加在.mobileConfig文件上。

我有使用iphone配置實用程序創建的配置文件。當您將.p12文件附加到您的配置文件時,將會更改。

創建.mobileconfig文件

密碼 password_value PayloadCertificateFileName後以下詞典將得到重視xml文件 certificate_name.p12 PayloadContent //從證書轉換數據

 </data> 
     <key>PayloadDescription</key> 
     <string>Provides device authentication (certificate or identity).</string> 
     <key>PayloadDisplayName</key> 
     <string>Certificate_name.p12</string> 
     <key>PayloadIdentifier</key> 
     <string>company.Identifier</string> 
     <key>PayloadOrganization</key> 
     <string>Company name</string> 
     <key>PayloadType</key> 
     <string>com.apple.security.pkcs12</string> 
     <key>PayloadUUID</key> 
     <string>UUId of the device</string> 
     <key>PayloadVersion</key> 
     <integer>1</integer> 
    </dict> 
+0

哎呀,對不起,我沒有正確地問我的問題。我真正想要做的是創建這個.mobileconfig文件,而不使用Apple iPhone配置實用程序。 – 2012-03-01 11:42:40

+0

@ElisonNiven檢查編輯的代碼可能會幫助你。 – 2012-03-01 12:32:06

+0

是的,我知道其他領域,我如何獲得 PayloadContent的值?這不是pkcs12文件的簡單base64。 – 2012-03-01 13:32:31

1

除了Anil提到的步驟外,還可以從pkcs12中讀取二進制數據證書,然後 使用base64編碼對其進行編碼。你可以把這些數據放在Anil提到的xml中。

<data>base64 encoded data 
</data> 
+0

從pkcs12文件中讀取二進制數據意味着什麼? – 2012-03-01 13:33:26

+0

我假設您正在使用一些代碼來生成xml文件。所以我的意思是以編程方式讀取pkcs12文件,然後在將其放入xml之前對其進行base64編碼。 – Nilesh 2012-03-01 13:35:05

+0

是的,但輸出與ACPU生成的輸出不同 – 2012-03-01 14:02:10

6

完成此操作的一種方法是base64編碼PKCS#12文件。例如,這適用於PHP

openssl_pkcs12_export($strCertPEM, $strCertPkcs12, $resKey, $strCertPW);  
$arrCertBase64 = str_split(base64_encode($strCertPkcs12), 52); 
$xmlUserCertPlist = plistVar('PayloadContent',$arrCertBase64,'data'); 

function plistVar($key,$var,$type) 
{ 
    //...snip... 
    if ($type == 'data') return plistData($key,$var); 
    //...snip... 
} 

function plistData($key,$arr) 
{ 
    //...snip... 
    $xml = "<key>". $key ."</key>\n"; 
    $xml .= "<data>\n"; 
    foreach ($arr as $val) { $xml .= $val."\n"; } 
    $xml .= "</data>\n"; 
    return $xml; 
} 
-3

您可以使用蘋果腳本來創建一個帶有p12的mobileconfig。我已經能夠做到,而且效果很好。恐怕我不能分享代碼,但我可以說它的工作原理。

0

我碰巧在現在正在通過這個權限工作,部署腳本爲Mac OS工作站生成n.mobileconfig文件。

它有助於引用802.1X Authentcation上的官方Apple文檔,因爲它們確實提供了一個XML模板和註釋。 另外,許多其他地方引用的是mactls.sh。我使用該模板來生成我的移動設備。

要獲取PKCS12文件,貓現有PKCS12文件的base64內容到OpenSSL:已

B64PK12=$(cat ${PK12} | openssl enc -base64); 

使用該變量插值到您的XML,只要你使用的模板供您mobileconfig文件。

我最初包含了RADIUS CA和解密的PKCS12文件內容,只導入了CA,儘管它沒有被base64編碼。在base64編碼CA和pkcs12內容之後,兩者都被添加到指定的Keychain中。

希望這會有所幫助。