2012-03-01 70 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中。

希望这会有所帮助。