c# - X509Certificate2 构造函数引发 Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException : There is not enough space on the disk

标签 c# azure security x509certificate x509certificate2

我遇到了类似的问题,描述为 here 。 这是一个 .NET Core 3.1 应用程序,在 Azure 应用服务中作为 Azure WebJob 运行。 根据上面链接中的讨论,我认为这是目录中文件计数的问题,我无法确定哪个目录已满。 Kudu 门户上的环境页面显示了这一点,基本上似乎不是整体磁盘空间问题 -

D:\home usage: 57,344 MB total; 56,795 MB free
d:\local usage: 11,264 MB total; 10,683 MB free

我也确实查看了上面链接中提到的路径,但没有取得多大成功。 在我尝试相关问题中建议的代码修复之前,有没有办法找出哪个是有问题的路径?


[08/02/2020 09:20:53 > 4708f0: INFO] Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException: There is not enough space on the disk.
[08/02/2020 09:20:53 > 4708f0: INFO]    at Internal.Cryptography.Pal.CertificatePal.FilterPFXStore(Byte[] rawData, SafePasswordHandle password, PfxCertStoreFlags pfxCertStoreFlags)
[08/02/2020 09:20:53 > 4708f0: INFO]    at Internal.Cryptography.Pal.CertificatePal.FromBlobOrFile(Byte[] rawData, String fileName, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags)
[08/02/2020 09:20:53 > 4708f0: INFO]    at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(Byte[] rawData, String password, X509KeyStorageFlags keyStorageFlags)
[08/02/2020 09:20:53 > 4708f0: INFO]    at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte[] rawData, String password)

最佳答案

除非 PFX 加载了 X509KeyStorageFlags.EphemeralKeySet,否则私钥 Material 将写入磁盘。具体位置取决于 PFX 中的信息,但 99.99% 的所有 PFX 加载中使用的目录都记录在 https://learn.microsoft.com/en-us/windows/win32/seccng/key-storage-and-retrieval#key-directories-and-files 中。 .

(在 0.01% 的情况下,PFX 内容表示将 key 加载到使用其他位置的其他存储提供程序中。)

或者,除非您正在执行少数需要命名 key 的操作之一,否则请在加载 PFX 时指定 EphemeralKeySet

关于c# - X509Certificate2 构造函数引发 Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException : There is not enough space on the disk,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63274366/

相关文章:

c# - 网络流接收数据与 '\0' 混合

c# - Microsoft Bot Framework - 如何将数据从 Azure 数据库获取到我的 Bot 项目?

azure - 加速 Visual Studio Team Services 中的解决方案构建(原为 VS Online)

mysql - 为azure mysql提供sequelize安全连接

security - 通过代理实现 SSL

asp.net-core - 声明类型 URL

c# - MSTest、MyClassInitialize 和实例变量

C# asp.net 将具有 long 属性的对象传递给前端会更改它的值

c# - 统一从数组实例化

php - 如何防止 PHP 中的 SQL 注入(inject)?