c# – Azure Web应用程序偶尔会抛出CryptographicException:Keyset不存在

我在Azure上托管了一个Identity Server Web应用程序.它的根目录中有一个.pfx文件用于签名.问题是,当新发布它完全正常但在一段时间后它开始抛出CryptographicException:Keyset不存在.

基于CryptographicException KeySet does not exists我会认为这是一个文件访问问题,但是为什么突然出现的azure会搞乱文件访问.

解决方法:

我建议您不要先从磁盘检索签名证书.而是将证书上传到Azure门户中的关联Web应用程序.

并在应用程序启动时检索证书

就像是.

X509Certificate2 Certificate = null;
var certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
certStore.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
var certCollection = certStore.Certificates.Find(X509FindType.FindByThumbprint,"CERTIFICATE_THUMBPRINT_HERE",false);
Certificate = certCollection[0];

相关文章

Microsoft云包括了Azure、PowerPlatform、Microsoft365、Git...
《WindowsAzurePlatform系列文章目录》 我们在使用AzureAPI...
微软免费使用一年的Azure虚拟机,默认提供了一个64G的磁盘,...
上篇请访问这里做一个能对标阿里云的前端APM工具(上)样本多...
一年一度的MicrosoftBuild终于来了,带来了非常非常多的新技...