I am using IdentityServer3 for authentication. The IdentityServer3 is using Signing certificate ( the certificate that is used for signing tokens) created using makecert ar per this article.
makecert -r -pe -n "CN=SigningOnlyCert" -b 01/01/2015 -e 01/01/2020 -sky signature -a sha256 -len 2048 -ss my -sr LocalMachine
This signing only certificate is been working fine with identyserver3
Now I am trying to add SAML2 external provider using SustainSys library. I configured SPOptions to load the same signing only certificate. like
Saml2AuthenticationOptions.SPOptions.ServiceCertificates.Add(LoadCertificateFromWindwosStore())
However its throws error
Provided certificate is not valid for encryption/decryption. There may be insufficient permissions to its private key in the windows certificate store or the certificate itself may not have the correct purposes. If you only want to use it for signing, set the Use property to Signing (CertificateUse.Signing).
When i debug library code, the actual exception is Bad Key
. as mentioned in #412
Now sure why this certificate is not working with SustainSys, when it works with IdentityServer3?
(Note that if i create new SSL certificate as per @brockallen article,
makecert -r -pe -n "CN=SSLCert" -b 01/01/2015 -e 01/01/2020 -sky exchange -a sha256 -len 2048 -ss my -sr localMachine
then SustainSys library works with SSL certificate. But not with signonly certificate )