Asp .net Core 3.1 example not working on windows 10

I could not get the .net core 3.1 Example working on windows 10 laptop. Both IDP and SP failed on reading the private key file. I even tried and regenerated the files and still could not get this working.

An unhandled exception occurred while processing the request.
WindowsCryptographicException: Access denied.
Internal.Cryptography.Pal.CertificatePal.FilterPFXStore(byte[] rawData, SafePasswordHandle password, PfxCertStoreFlags pfxCertStoreFlags)
SamlCertificateException: The X.509 certificate could not be loaded from the file d:\temp\SAMLv20.Core-evaluation\SAML for .NET Core\Examples\NET-Core-3.1\SSO\ExampleServiceProvider\certificates/sp.pfx.
ComponentSpace.Saml2.Certificates.CertificateLoader.LoadCertificateFromFileAsync(string certificateFile, string certificatePassword)


An unhandled exception occurred while processing the request.
WindowsCryptographicException: Access denied.
Internal.Cryptography.Pal.CertificatePal.FilterPFXStore(byte[] rawData, SafePasswordHandle password, PfxCertStoreFlags pfxCertStoreFlags)
SamlCertificateException: The X.509 certificate could not be loaded from the file d:\temp\SAMLv20.Core-evaluation\SAML for .NET Core\Examples\NET-Core-3.1\SSO\ExampleIdentityProvider\certificates/idp.pfx.
ComponentSpace.Saml2.Certificates.CertificateLoader.LoadCertificateFromFileAsync(string certificateFile, string certificatePassword)


Regards,
Prakash

Hi Prakash,

Normally there aren’t permission errors accessing the certificate files. You’ll need to ensure you have permission to access both the PFX files and the private key containers. For more information, please refer to:

https://www.componentspace.com/Forums/29/Troubleshooting-Loading-X509-Certificates

[quote]
ComponentSpace - 8/5/2020
Hi Prakash,

Normally there aren't permission errors accessing the certificate files. You'll need to ensure you have permission to access both the PFX files and the private key containers. For more information, please refer to:

https://www.componentspace.com/Forums/29/Troubleshooting-Loading-X509-Certificates
[/quote]

Running Visual studio as administrator solved this issue.

Thanks for your help.

Thanks for the update. I’m not sure why that was required but I’m pleased you got it working. The alternative would have been to set the permissions.