.net - Power BI Embedded,使用证书获取身份验证令牌时出现问题 - 出现错误“无效的提供程序类型”
问题描述
我正在使用嵌入在本地 Intranet 应用程序中的 Power BI 并获取身份验证令牌,我正在使用证书。我面临的问题是,在本地进行时效果很好。但是当发布到我们的开发服务器时,它只在一个实例上工作,而不是在其他实例上,比如本地的 QA 或 UAT 环境。
这可能是什么原因?是因为我们没有正确使用证书吗?奇怪的是,如果它失败了,为什么它只适用于一个网络服务器实例而不是其他网络服务器?
****这是我们用于获取身份验证令牌的代码片段:****
var tenantSpecificURL = AuthorityUrl.Replace("common", Tenant);
var authenticationContext = new AuthenticationContext(tenantSpecificURL);
AzureServiceTokenProvider azureServiceTokenProvider = new AzureServiceTokenProvider();
var certificatepath = AppDomain.CurrentDomain.BaseDirectory + @"App_Data\SFA.pfx";
var xCert = new X509Certificate2(certificatepath, "XXXXXXX", X509KeyStorageFlags.PersistKeySet);
var credential = new ClientAssertionCertificate(ApplicationId, xCert);
//this is where i believe it is failing
authenticationResult = authenticationContext.AcquireTokenAsync(ResourceUrl, credential).Result;
//End of Authentication
string AccessToken = null; //
var m_tokenCredentials = new TokenCredentials(authenticationResult.AccessToken, "Bearer");
string Token = "";
这是我得到的错误。
ExceptionMessage":"指定的提供程序类型无效。\r\n","ExceptionType":"System.Security.Cryptography.CryptographicException","StackTrace":" atSystem.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 在 System.Security.Cryptography.RSACryptoServiceProvider.GetKeyPair()\r\n 在 System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize, CspParameters parameters, Boolean useDefaultKeySize)\r\n 在 System.Security.Cryptography .X509Certificates.X509Certificate2.get_PrivateKey()\r\n 在 System.IdentityModel.Tokens.X509AsymmetricSecurityKey.get_PrivateKey()\r\n 在 System.IdentityModel.Tokens.X509AsymmetricSecurityKey.GetAsymmetricAlgorithm(字符串算法,Boolean privateKey)\r\n 在 Microsoft.IdentityModel.Clients.ActiveDirectory.Internal.Platform.SigningHelper.SignWithCertificate(字符串消息,X509Certificate2 证书)\r\n 在
Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext.d__59.MoveNext()"}
解决方案
推荐阅读
- assembly - 无法在程序集中遵循 rbp 值
- jupyter-notebook - 我正在尝试将我的笔记本放在 Kaggle 上的特定目录中
- c# - 为什么 MonoBehaviour Start() 上的类引用丢失
- python - 使用 seaborn 绘制 numpy 变量列表
- ios - 是否可以在类/结构实例方法中调用 GameScene 函数?
- angularjs - 如何在不同的页面中加载图表
- tensorflow - ValueError: Tensor Tensor("dense_1/Sigmoid:0", shape=(?, 1), dtype=float32) 不是该图的元素
- python - 如何将用于获取语音频道中成员列表的 discord.py discord 机器人代码转换为新的 discord.py 版本?
- java - 读取缓冲图像显示透明度但输出错误的 alpha 值
- python-3.x - 无法使用 slack api files.upload 上传文件