Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing pfx file into iOS application

I'm working on an iOS (iPhone/iPad) app that does a web service call where one of the parameters is a .pfx file.

I would like for the user to be able to import his own .pfx file into the app by selecting its attachment in an email (the app already does this for a custom file type, whose entries are not shown below, but are very similar).

In the app's Info.plist file, I've added an entry in the CFBundleDocumentTypes tag and one in the UTExportedTypeDeclarations tag, as shown below. In the UTExportedTypeDeclarations I used for the identifier 'com.rsa.pkcs-12', which is one of the UTI's for pfx files. I looked up and entered the standard MIME type of a pfx file (application/x-pkcs12).

<?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>CFBundleDocumentTypes</key>
<array>
            ...
    <dict>
        <key>CFBundleTypeName</key>
        <string>Personal Information Exchange</string>
        <key>LSHandlerRank</key>
        <string>Owner</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>com.rsa.pkcs-12</string>
        </array>
    </dict>
</array>
...
    <key>UTExportedTypeDeclarations</key>
<array>
            ...
    <dict>
        <key>UTTypeConformsTo</key>
        <array/>
        <key>UTTypeDescription</key>
        <string>Personal Information Exchange</string>
        <key>UTTypeIdentifier</key>
        <string>com.rsa.pkcs-12</string>
        <key>UTTypeTagSpecification</key>
        <dict>
            <key>public.filename-extension</key>
            <string>pfx</string>
            <key>public.mime-type</key>
            <string>application/x-pkcs12</string>
        </dict>
    </dict>
</array>
</dict>
</plist>

This doesn't work. When I open a pfx file attachment in Mail, it opens in Settings (it wants to install the file as a profile). Of course, the pfx file type already exists in iOS, so it should not really be necessary to make an entry in UTExportedTypeDeclarations; however, removing this entry makes no difference. The same behaviour occurs when I use a custom identifier in both entries (instead of "com.rsa.pkcs-12").

I would not like to force the user to change the extension of the file of the attachment. Is there a way I can tell iOS to ask the user whether to open the file with Settings or my app?

like image 707
bgh Avatar asked Apr 28 '12 14:04

bgh


People also ask

How do I import a PFX certificate?

Start Windows Explorer and select and hold (or right-click) the . pfx file, then select Open to open the Certificate Import Wizard. Follow the procedure in the Certificate Import Wizard to import the code-signing certificate into the Personal certificate store.

Can I open a PFX file?

The contents of a pfx file can be viewed in the GUI by right-clicking the PFX file and selecting Open (instead of the default action, Install). This will open mmc and show the pfx file as a folder. Open the pfx folder and the Certificates subfolder, and you will see the certificate(s) contained in the pfx.

What program opens PFX files?

PFX files may be found in Mac and Microsoft Windows systems, and the applications that can be used to open these . pfx files are versions of Adobe Acrobat X and Adobe Reader compatible with Mac or Microsoft Windows environments.


1 Answers

It looks like this is not possible for a special file such as a .pfx .

I've changed my app so that it accepts files with a special extension. The app instructs the user to change the extension of the .pfx file to the special extension before emailing it to him/herself to import it into the app.

like image 71
bgh Avatar answered Oct 05 '22 16:10

bgh