-
-
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
SSL Certificate add failed, Error: 1321 A specified logon session does not exist. It may already have been terminated. #566
Comments
Hey @gfody, thanks for reaching out. Unfortunately, I don't have any insight as to why this would suddenly break for you. The code for importing the certs hasn't changed in 3 years. The only Let's Encrypt related thing that has changed recently was the expiration of the old DST cross-signed root. But it doesn't seem like that should affect Windows' ability to access the private key for your cert. LE certs haven't been chaining to that root in quite some time. You could also rule this out by temporarily switching to another ACME CA. Based on the previous issue and some web searching surrounding the error message, there doesn't seem to be any one magic reason this happens. It might be related to the .NET version PowerShell is running on. So differences between running on PowerShell 7+ or 5.1 might matter. It might also be related to a recent hotfix from Microsoft at the OS level. Here's a thread with various potential workarounds/solutions. If you can give me some details about your specific environment (OS version, PowerShell version, .NET Framework version if on PowerShell 5.1), I can see if I can try to reproduce it on my end. |
the netsh command succeeded after re-importing the pfx via certlm.msc
appreciate it! here's the output of
|
Hi, I'm running into this same issue on Server 2016, PowerShell 7.5. My workaround was to use openssl to build a new pfx file from fullchain.cer and cert.key. Windows certificate store said the cert installed by Install-PACertificate had a private key associated with it, but when you select Manage private keys there weren't any assigned. Very odd! I haven't run into this issue on Server 2019 or Server 2022 yet so I plan on upgrading this 2016 server sooner than later. |
This is often related to private key permissions, or it can be an issue where a private key is accidentally being created as "ephemeral" instead of persisting to the machine key set. As an aside if you run a task as Local System there is/was also a windows bug where the PFX needed to be stored twice for it to stick. |
As a test I requested a certificate for a different hostname on a 2022 machine, then tried to import the fullchain.pfx file on the 2016 machine and got the parameter incorrect error and the private key was missing, even though when you view the certificate in the local machine store it says a matching key is installed. I then used openssl to combine the fullchain.cer and cert.key files on the 2022 machine, then imported that pfx file into the server 2016 local machine store and that worked perfectly and the private key showed up and I could apply it to IIS sites. I can replicate this issue on every 2016 machine we have at this point, but we have a workaround until we can get them upgraded to 2019 or later. Maybe it's something to do with how Sectigo is sending the certificates back to us that isn't immediately compatible with 2016 anymore? |
I think what @webprofusion-chrisc was saying is that you shouldn't need the step where you use openssl. If you just delete the imported copy that's not working and re-import using the same fullchain.pfx, it should work when importing the second time. |
Yep, tried that multiple times on several machines and ran into the same issue with fullchain.pfx as well. The same pfx file works on on 2019 and 2022 so I'm at a bit of a loss. |
Oh wait, @rmbolger does Posh-ACME use modern PFX algs by default? For Certify The Web we've previously found that doesn't work for older windows or instances that have been in-placed upgraded. |
Not by default. You'd need to opt-in via the Part of me really wants to spin up a 2016 box and get a reliable repro for this that I can hack on. The other part doesn't want to bother with an OS that has been out of mainstream support for 3 years. But there are other folks who have seen similar problems on more recent OS versions too. So it's possible that repro'ing on 2016 would potentially lead to fixes for other versions. |
Aha, thank you everyone. After your recent comments I went back through my entire script and found I was setting UseModernPFXEncryption to $true in my default certificate parameters. I added a check so if the server version is 2016 it sets that to $false and everything is working now. |
Hah, nice! At least one mystery solved. Hey @gfody, I know you're not running Server 2016. But can you double check whether your order has the ModernPfxEncryption flag enabled? (Get-PAOrder).UseModernPfxEncryption |
I started getting this error message, these scripts were working before. same symptoms as #157 but I'm using 4.25.1
when I try to bind it to a port I get the error in the title
I've tried removing and re-installing it but it keeps giving the same error. I can compare the certs in certlm the one that's not working complains if I goto "All Tasks -> Manage Private Keys..." it says "No keys found for certificate!" though if I view it it says "You have a private key that corresponds to this certificate."
The only visible difference in certlm is that the broken one has friendly name matching the domain name.
The text was updated successfully, but these errors were encountered: