powershell icon indicating copy to clipboard operation
powershell copied to clipboard

[BUG] - `Connect-PnPOnline`: Keyset does not exist

Open elementlu opened this issue 4 years ago • 5 comments

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

elementlu avatar Jan 11 '22 15:01 elementlu

I am actually able to reproduce the error every day. A reimport of the cert fixes it temporarily.

elementlu avatar Jan 13 '22 17:01 elementlu

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

gautamdsheth avatar Jan 21 '22 12:01 gautamdsheth

I will attempt your comment. I was using - New-PnPAzureCertificate for creation

elementlu avatar Jan 26 '22 22:01 elementlu

@elementlu - Did you try @gautamdsheth's suggestion?

veronicageek avatar Feb 05 '22 14:02 veronicageek

Closing this due to lack of response.

gautamdsheth avatar Mar 05 '22 15:03 gautamdsheth