JBines / Remove-StaleGuests

This script removes stale Azure AD Guest accounts.
MIT License
17 stars 13 forks source link

Certificate does not have a private key #10

Closed dfoster3 closed 2 years ago

dfoster3 commented 2 years ago

When using the Azure app registration, it will not allow a certificate upload with extension .pfx. But a certificate with the .cer extension doesn't have a private key, which in turn throws an error in powershell. I've run this script before, successfully, but I can't for the life of me figure out what could have been different. I've tried both the original certificate, and a new one. I created a self-signed cert with private key, but again, it can only be exported with the pfx extension.

JBines commented 2 years ago

hiya! so you need both a pfx and a cer for the same cert. They can't be different but must match.

install your pfx on your computer with the private key and then export without the private key to create the cer.

https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-view-certificates-with-the-mmc-snap-in

Find the “Certificates” folder on the left menu. Go to: Certificates > Personal > Certificates. Right-click on the certificate you wish to export and go to All Tasks and hit Export. Hit Next on the Certificate Export Wizard to begin the process. Select “No, don't export the private key” and hit next.

then select cer and upload this to the azure app

dfoster3 commented 2 years ago

Doh! Didn't think to use both. Actually just found documentation from MSoft about doing this very thing. Appreciate the help!

JBines commented 2 years ago

no worries glad it worked out :)