SAML绑定:在Azure上获取X509Certificate2.PrivateKey时出错
ITFoxtec Identity SAML 2.0库包含一个函数,用于绑定从签名证书中提取私钥的请求SAML绑定:在Azure上获取X509Certificate2.PrivateKey时出错,azure,certificate,private-key,x509certificate2,itfoxtec-identity-saml2,Azure,Certificate,Private Key,X509certificate2,Itfoxtec Identity Saml2,ITFoxtec Identity SAML 2.0库包含一个函数,用于绑定从签名证书中提取私钥的请求 if(certificate is Saml2X509Certificate) { return (certificate as Saml2X509Certificate).GetRSAPrivateKey(); } else { return certificate.GetRSA
if(certificate is Saml2X509Certificate)
{
return (certificate as Saml2X509Certificate).GetRSAPrivateKey();
}
else
{
return certificate.GetRSAPrivateKey();
}
它在本地机器上工作,但在azure上,它给出了以下错误。
System.Security.Cryptography.CryptographicException: Invalid provider type specified.
at System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean
randomKeyContainer)
at System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType, CspParameters
parameters, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle&
safeKeyHandle)
at System.Security.Cryptography.RSACryptoServiceProvider.GetKeyPair()
at System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize, CspParameters
parameters, Boolean useDefaultKeySize)
at System.Security.Cryptography.X509Certificates.X509Certificate2.get_PrivateKey()
at System.Security.Cryptography.X509Certificates.RSACertificateExtensions.GetRSAPrivateKey(X509Certificate2 certificate)
at ITfoxtec.Identity.Saml2.X509Certificate2Extensions.GetSamlRSAPrivateKey(X509Certificate2 certificate)
at ITfoxtec.Identity.Saml2.Saml2Binding1.BindInternal(Saml2Request saml2RequestResponse)
at ITfoxtec.Identity.Saml2.Saml2RedirectBinding.BindInternal(Saml2Request saml2RequestResponse, String messageName)
at ITfoxtec.Identity.Saml2.Saml2Binding
1.Bind(Saml2Request saml2Request)
不确定是saml库问题还是azure配置问题,因为它在本地计算机上工作。
我正在使用TestWebApp示例中提供的证书。所以,它看起来没有损坏
有人知道这背后的原因吗 如果您使用的是Azure应用程序服务,那么问题可能是您需要使您的web应用程序可以访问SSL/TLS证书私钥 添加一个名为WEBSITE_LOAD_CERTIFICATES的应用程序设置,并将其值设置为证书的指纹,将使您的web应用程序可以访问该设置