Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import-PFXCertificate password issue

Tags:

powershell

pfx

I have a client side cert PFX from some idiot to allow some users access his website and I need to script it so I can allow multiple users to auto import this cert into the local store during a logon to our RDS environment.

This cert also came with a long complicated password that I need to pass to said function.

So I had the bright idea of using PS function Import-PFXCertificate to do this.

$PlainTextPass = "f4@)]\as1"

$pfxpass = $PlainTextPass |ConvertTo-SecureString -AsPlainText -Force  

Import-PfxCertificate -filepath C:\important.pfx cert:\CurrentUser\my -
Password  $pfxpass

It fails with this error, and I can't find any direct reference to it on the web.

Import-PfxCertificate : The PFX file you are trying to import requires either a different password or membership in an Active Directory principal to which it is protected.

The test user I am running against is a domain admin. Not that should matter as it's installing the cert into CurrentUser

like image 993
Andy Denley Avatar asked May 05 '17 05:05

Andy Denley


1 Answers

Try surrounding the plain text password with single quotes instead of double quotes. I had a password with $ in it that gave me the same error until I swapped the quotes.

like image 89
ctschap Avatar answered Oct 13 '22 19:10

ctschap