[BUG] - `Connect-PnPOnline`: Keyset does not exist
Reporting an Issue or Missing Feature
If I run Connect-PnPOnline locally using a certificate (stored in the local machine certificate store) and supplying the parameters (Tenant, Thumbprint and ClientId ) the command fails:
Connect-PnPOnline -Url $Url -Tenant $tenant -Thumbprint $thumbprint -ClientId $clientId Error message: Connect-PnPOnline: Keyset does not exist
Attempts to replace the local certificate works, but after a period of time, such as a week, the keyset does not exist error returns.
This was mentioned here, but I'm not sure what the resolution is: https://github.com/pnp/powershell/issues/106
Expected behavior
Would expect the command to successfully establish a connection with SharePoint Online
Actual behavior
Error message produced: Connect-PnPOnline: Keyset does not exist
Steps to reproduce behavior
I use this command to import the cert: Import-PfxCertificate -Exportable -CertStoreLocation Cert:\LocalMachine\My -FilePath .$certname.pfx #Install certificate
and then this command to connect: Connect-PnPOnline -Url $Url -Tenant $tenant -Thumbprint $thumbprint -ClientId $clientId
then after a week or so, I have remove the cert and run import line again.
What is the version of the Cmdlet module you are running?
1.9.0
Which operating system/environment are you running PnP PowerShell on?
- [x] Windows
- [ ] Linux
- [ ] MacOS
- [ ] Azure Cloud Shell
- [ ] Azure Functions
- [ ] Other : please specify
I am actually able to reproduce the error every day. A reimport of the cert fixes it temporarily.
This looks like some sort of a permission issue with your local machine or the account that you use to access the certificate.
Maybe you can use Get-PnPAzureCertificate cmd and try ??
https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/get-pnpazurecertificate?view=sharepoint-ps
I will attempt your comment. I was using - New-PnPAzureCertificate for creation
@elementlu - Did you try @gautamdsheth's suggestion?
Closing this due to lack of response.