-
-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Install flag doesn't properly import private key in some environments #122
Comments
Are you using the native installation method (via the However, just to verify if you are doing it manually, are you giving it the PFX password in addition to the path to the file? That would be necessary in order for it to extract and import the private key. $mycert = Get-PACertificate
Import-PfxCertificate $mycert.PfxFullChain -Password $mycert.PfxPass Also, is this on Server 2012 or 2012 R2? |
I'm using the -Install parameter in the module. Once I noticed the issues I played around with invoking Import-PfxCertificate myself with a few variations including specifying the password, finally I was able to get past it using the certutil program mentioned in the linked bug report:
Which is a bit gross, but at least it works. So yes, this isn't really a blocker for me, I just thought I'd give you the heads up |
That is a super annoying bug. Was it 2012 or 2012 R2? I'd like to reproduce on my end and perhaps try to throw in some sort of workaround. The module also has an alternate method for import on legacy OSes that don't support the try {
$pfxBytes = [IO.File]::ReadAllBytes($fullChainPath)
$pfx = New-Object Security.Cryptography.X509Certificates.X509Certificate2($pfxBytes,$certPassword,'Exportable,PersistKeySet')
$store = New-Object Security.Cryptography.X509Certificates.X509Store('My','LocalMachine')
$store.Open("MaxAllowed")
$store.Add($pfx)
$store.Close()
} finally {
if ($store -ne $null) { $store.Dispose() }
if ($pfx -ne $null) { $pfx.Dispose() }
} |
Oh sorry, forgot to mention, I'm using an azure 2019 image |
Quick followup. You said you were able to use the cert for IIS but not RDS. How were you attempting to import into RDS? And is this a full fledged RDS setup or just remote admin mode? |
Nevermind on the previous questions. I managed to reproduce this fairly reliably. I still can't figure out when MS broke In any case, the code I was using for downlevel OSes works just fine and doesn't exhibit the same problem. So I think I'm just going to change the internal function to use that everywhere. |
I know you said never mind, but it's a full fledged RDS setup, and I've been using powershell https://docs.microsoft.com/en-us/powershell/module/remotedesktop/set-rdcertificate?view=win10-ps |
As per: MicrosoftDocs/windows-powershell-docs#295
I seem to be able to use the imported certificate for IIS but not for RDS, not really sure what's up with that.
If I manually import fullchain from the GUI I can use it for RDS, but GUI is no fun
The text was updated successfully, but these errors were encountered: