azure-ad-b2c - 间歇性 Azure AD B2C 异常 : IDX10614: AsymmetricSecurityKey. GetSignatureFormater() 引发异常

标签 azure-ad-b2c azure-ad-b2c-custom-policy

我们使用带有自定义策略的 AAD B2C 一段时间了,一切都按预期运行,但突然间我们开始遇到登录策略的异常(exception)情况。更糟糕的是,有时它确实有效,但五分之四我们会遇到异常。

我们通过将策略链接到 Application Insights 成功地挖掘了错误,以下是我们得到的结果:

"Kind": "FatalException",
    "Content": {
      "Time": "9:05 PM",
      "Exception": {
        "Kind": "Handled",
        "HResult": "80131509",
        "Message": "IDX10614: AsymmetricSecurityKey.GetSignatureFormater( 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256' ) threw an exception.\nKey: 'System.IdentityModel.Tokens.X509AsymmetricSecurityKey'\nSignatureAlgorithm: 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256', check to make sure the SignatureAlgorithm is supported.\nException:'System.Security.Cryptography.CryptographicException: Invalid provider type specified.\r\n\r\n   at System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer)\r\n   at System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType, CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle)\r\n   at System.Security.Cryptography.RSACryptoServiceProvider.GetKeyPair()\r\n   at System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize, CspParameters parameters, Boolean useDefaultKeySize)\r\n   at System.Security.Cryptography.X509Certificates.X509Certificate2.get_PrivateKey()\r\n   at System.IdentityModel.Tokens.X509AsymmetricSecurityKey.get_PrivateKey()\r\n   at System.IdentityModel.Tokens.X509AsymmetricSecurityKey.GetSignatureFormatter(String algorithm)\r\n   at System.IdentityModel.Tokens.AsymmetricSignatureProvider..ctor(AsymmetricSecurityKey key, String algorithm, Boolean willCreateSignatures)'.\nIf you only need to verify signatures the parameter 'willBeUseForSigning' should be false if the private key is not be available.",
        "Data": {},
        "Exception": {
          "Kind": "Handled",
          "HResult": "80090014",
          "Message": "Invalid provider type specified.\r\n",
          "Data": {}
        }
      }
    }

我不确定发生了什么变化,也不知道这种情况是如何突然发生的。我们是否使用隐身模式并不重要。

此外,微软方面没有报告任何中断情况。

任何线索将不胜感激!

最佳答案

通过此处找到的信息解决:StackOverflow question

因为我们还使用了 Invite Flow ,我使用了其中提到的 New-SelfSignedCertificate 命令。

现在我已经使用此 Microsoft doc 中的信息重新生成了证书。并从上面的 StackOverflow 线程附加 Provider 参数:

PS C:\WINDOWS\system32> New-SelfSignedCertificate `
>>     -KeyExportPolicy Exportable `
>>     -Subject "CN=***.onmicrosoft.com" `
>>     -KeyAlgorithm RSA `
>>     -KeyLength 2048 `
>>     -KeyUsage DigitalSignature `
>>     -NotAfter (Get-Date).AddMonths(24) `
>>     -CertStoreLocation "Cert:\CurrentUser\My" `
>>     -Provider "microsoft enhanced rsa and aes cryptographic provider"

虽然我不确定为什么它突然停止工作,但我猜可能是微软更新了一些东西。

无论如何,它现在似乎有效,所以我们拭目以待。

关于azure-ad-b2c - 间歇性 Azure AD B2C 异常 : IDX10614: AsymmetricSecurityKey. GetSignatureFormater() 引发异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64507542/

相关文章:

带有必填字段的 Azure B2C 注册策略

azure - 在 Azure AD B2C 中启用电子邮件地址或电话号码作为用户标识符

azure - 无法调用 RN.createPublicClientApplication

azure-active-directory - Azure Active Directory B2C AADB2C90051 : No suitable claims providers were found

azure - 是否有任何选项可以在 azure ad b2c 中使用自定义策略设置密码重置限制?

azure - 将 Multi-Tenancy Azure AD 与 Azure AD B2C 结合使用时,如何在颁发的 token 中包含角色?

azure-active-directory - 如何使用 msal.js 和 React js 从 B2C 强制刷新 id_token

Azure AD B2C 用户创建

azure - 如何在 Azure Active Directory 上配置自定义身份验证服务(使用 Windows Identity Framework 开发)

xamarin - 是否有人使用 Microsoft.Identity.Client 1.1.0-preview 成功实现了 Azure Active Directory B2C 进行身份验证?