SAML绑定:在Azure上获取X509Certificate2.PrivateKey时出错

问题描述 投票:1回答: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示例中提供的证书。因此,它看起来没有损坏。

有人知道背后的原因吗?

azure certificate private-key x509certificate2 itfoxtec-identity-saml2
1个回答
0
投票

如果使用的是Azure App Service,则可能是您需要使Web应用程序可以访问SSL / TLS证书私钥。

添加名为WEBSITE_LOAD_CERTIFICATES的应用程序设置(其值设置为证书的指纹将使其可用于您的Web应用程序。

© www.soinside.com 2019 - 2024. All rights reserved.