1

ITFoxtec Identity SAML 2.0 库包含一个函数来绑定从签名证书中提取私钥的请求。

 if(certificate is Saml2X509Certificate)
        {
            return (certificate as Saml2X509Certificate).GetRSAPrivateKey();
        }
        else
        {
            return certificate.GetRSAPrivateKey();
        }

它在本地机器上工作,但在天蓝色上,它给出了以下错误。

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.Saml2Binding1.Bind(Saml2Request saml2Request)  
.

不确定是 saml 库问题还是 azure 配置问题,因为它适用于本地计算机。我正在使用测试 webapp 示例中提供的证书。所以,它看起来并没有损坏。

有谁知道这背后的原因?

4

1 回答 1

1

如果您使用的是 Azure 应用服务,那么问题可能在于您需要使 SSL/TLS 证书私钥可供您的 Web 应用程序访问。

添加一个名为 WEBSITE_LOAD_CERTIFICATES 的应用程序设置,并将其值设置为证书的指纹,这将使您的 Web 应用程序可以访问它。

于 2020-05-04T13:05:50.253 回答