Wednesday, April 27, 2011

Manually Creating a MobileConfig file including certificates
I've spent a long time trying to automate the creation of MobileConfig files (They are the configuration files for Apple Devices (iPod, iPad and iPhones). The format is relatively simple (i.e. XML) but I have always been stuck when trying to include a personal certificate in the file. Now I am no longer stuck!
I found out that all you need is the certificate as a .PFX file, and then use CERTUTIL with the following syntax
certutil -encode alginald.pfx alginald.enc
then you need to remove the first and last lines of the file (the BEGIN CERTIFICATE and END CERTIFICATE) and then add it to the mobileconfig file. Yippee...
I'm using powershell to script the creation, so a couple more pointers..
To strip the first and last lines..
$content=gc alginald.enc
$newcontent=$content[1..($content.length-2)]
I also use the add-content command to add to the end of a file, but it also needs the UTF8 encoding part.. i.e.
add-content alginald.mobileconfig -value $newcontent -encoding UTF8
Hope this helps...

Labels: , , ,


This page is powered by Blogger. Isn't yours?