将pkcs12插入mobileconfig文件

时间:2012-03-01 11:14:12

标签: iphone ios xml ssl-certificate pkcs#12

如何在.p12文件中插入.mobileconfig文件?

Apple配置实用程序当前在.p12文件中执行一些未知的转换/编码,同时将其插入.mobileconfig(它只是一个XML文件)。

我想通过直接创建XML文件而不使用Apple iPhone配置实用程序来创建此.mobileconfig文件。

由于

5 个答案:

答案 0 :(得分: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;
}

答案 1 :(得分:1)

如果要在iphone配置文件中插入.p12文件,只需在所选配置文件的iphone配置实用程序中选择凭据选项卡即可。当您configure时,它将ask for the .p12 file附加到.mobileConfig文件上。

我有使用iphone配置实用程序创建的配置文件。当您将.p12文件附加到配置文件中时,将会更改。

创建.mobileconfig文件后,以下字典将附加到xml文件

            密码             password_value             PayloadCertificateFileName             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>

答案 2 :(得分:1)

除了Anil提到的步骤之外,还要从pkcs12证书中读取二进制数据 使用base64编码对其进行编码。您可以将这些数据放在Anil提到的xml中。

<data>base64 encoded data
</data>

答案 3 :(得分:0)

我正好在目前的位置正在解决这个问题,部署脚本为Mac OS工作站生成n.mobileconfig文件。

它有助于引用802.1X Authentcation上的官方Apple文档,因为它们确实提供了XML模板及其相关说明。 此外,在许多其他地方引用的是mactls.sh。我使用该模板生成我的mobileconfigs。

要获取pkcs12文件的base64内容,请将现有的pkcs12文件转换为openssl:

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

如果您使用的是mobileconfig文件的模板,请使用该变量插入XML。

我最初包括RADIUS CA和解密的PKCS12文件内容,只有CA被导入,尽管它不是base64编码的。在base64编码CA和pkcs12内容之后,两者都被添加到指定的Keychain。

希望这有帮助。

答案 4 :(得分:-3)

您可以使用Apple脚本创建内置p12的mobileconfig。我已经能够做到这一点并且效果很好。我担心我无法分享代码,但我可以说它有效。

相关问题