使用 System.Security.Cryptography.RSACng 来签名和验证数据线程是否安全?

Is using System.Security.Cryptography.RSACng to sign and verify data thread safe?

我有一个 X509Certificate2 实例,其中包含从 .pfx 文件导入的 System.Security.Cryptography.RSACng 实例。

我不想每次需要使用时都从磁盘读取文件。

只有一个全局实例被多个线程使用是否安全?

我在 Linux 和 Windows 上使用 .Net Core 3.1。

不,RSACng class 不是线程安全的。

另外,请注意 class 在 Linux 或 Mac 上不可用。它是 Windows-only 实现。所以在应用程序中到处引用抽象 RSA class 而不是这个特定的实现。