How do you Import PFX file using iControl with Powershell?

Using 11.4.1, how do I import a pfx file using iControl/Powershell. In the UI, I navigate to System --> File Management --> SSL Certificate List. Click Import, change the “Import Type” drop down to PKCS 12 (IIS), enter a label for my cert in Certificate (ie: testCert), use “Choose File” to navigate to where I’ve stored the PFX and select the PFX. Enter the password needed by the PFX file (ie: testpassword) and click import.

I see under icontrol there is a ManagementKeyCertificate.pkcs12_import_from_file and ManagementKeyCertificate.pkcs12_import_from_file_v2

v2 is for 11.5 and above. It doesn’t work on 11.4. So just ManagementKeyCertificate.pkcs12_import_from_file

I look up the overloads for this and it seems fairly straightforward: void pkcs12_import_from_file(iControl.ManagementKeyCertificateManagementModeType mode, string[] ids, string[] file_names, string[] passwords, bool overwrite)

which I translate to

$icontrol.ManagementKeyCertificate.pkcs12_import_from_file(0,@(,"testCert"),@(,"c:\temp\testCert.pfx"),@("testPassword"),$false)

which blows up with Invalid filename. Filenames may only contain the following characters: [A-Za-z][0-9].-_/"

so I try variations on the filename including setting my location to c:\temp and trying

$icontrol.ManagementKeyCertificate.pkcs12_import_from_file(0,@(,"testCert"),@(,"testCert.pfx"),@("testPassword"),$false)

which gets error:2006D080:BIO routines:BIO_new_file:no such file""

and

$icontrol.ManagementKeyCertificate.pkcs12_import_from_file(0,@(,"testCert"),@(,"/temp/testCert.pfx"),@("testPassword"),$false)

which results in: error:02001002:system library:fopen:No such file or directory""

sooo… I guess the crux of my problem is: How do I specify where the pfx to import is located? I’ve seen a couple other questions with this same problem but they don’t have answers… so here’s my hat in the ring

There was mention in one of the posts that indicated that the certificate had to on the F5 device before these commands would work. I have looked for info on how to get the cert up to the LTM, but haven’t found it. I have yet to find a way to import certificates via PowerShell. These questions have been asked for a few years and it doesn’t appear F5 is doing anything to help resolve them. Good luck!

winscp or scp the certs to the /shared/cert directory, you will have to create the /shared/cert dir. You use your admin management gui username and password to access the directories.

Take a look at this posting DevCentral - An F5 Technical Community