System.PlatformNotSupportedException AesCryptoServiceProvider

发布于 2024-08-02 12:30:57 字数 977 浏览 3 评论 0原文

我有以下问题。

我创建了一个使用 AesCryptoServiceProvider 来加密和解密一些数据的类。我在 SharePoint WebPart 中使用该类,一切正常。我还在自定义 SharePoint Web 服务中的同一个 Web 应用程序上使用相同的类,并且每次调用 System.Security.Cryptography.AesCryptoServiceProvider 的构造函数时,它都会抛出 System.PlatformNotSupportedException 和以下堆栈跟踪。

System.PlatformNotSupportedException: The specified cryptographic algorithm is not supported on this platform.
   at System.Security.Cryptography.CapiNative.AcquireCsp(String keyContainer, String providerName, ProviderType providerType, CryptAcquireContextFlags flags, Boolean throwPlatformException)
   at System.Security.Cryptography.AesCryptoServiceProvider..ctor()
   at m2009_wu.ProvisioningLibrary.ConfigManager..ctor()

我尝试为不同的平台编译网络服务和包含类的库,而不进行任何更改。

我的开发环境运行的系统是 Windows Server 2008 Standard SP1 x64,带有 Microsoft Office SharePoint Server 2007 SP2 x64 和 Visual Studio 2008 SP1。服务器上安装了.Net Framework 3.5 SP1。

如果有人能指出我正确的方向,我将不胜感激。

亲切的问候 雷内·温德格尔

I've got the following problem.

I've created a class that uses AesCryptoServiceProvider to encrypt and decrypt some data. I'm using the class in a SharePoint WebPart and everything works fine. I'm also using the same class on the same webapplication in a custom SharePoint webservice and every time the constructor of the System.Security.Cryptography.AesCryptoServiceProvider is called it throws a System.PlatformNotSupportedException with the following stack trace.

System.PlatformNotSupportedException: The specified cryptographic algorithm is not supported on this platform.
   at System.Security.Cryptography.CapiNative.AcquireCsp(String keyContainer, String providerName, ProviderType providerType, CryptAcquireContextFlags flags, Boolean throwPlatformException)
   at System.Security.Cryptography.AesCryptoServiceProvider..ctor()
   at m2009_wu.ProvisioningLibrary.ConfigManager..ctor()

I've tried to compile the webservice and the library with the class in it for different platforms without any change.

The system my development environment is running on is a Windows Server 2008 Standard SP1 x64 with Microsoft Office SharePoint Server 2007 SP2 x64 and Visual Studio 2008 SP1. The .Net Framework 3.5 SP1 is installed on the server.

I'd be greatful if anyone could point me in the right direction.

Kind regards
Rene Windegger

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

泪之魂 2024-08-09 12:30:57

来自 MSDN:

PlatformNotSupportedException - 当前平台不支持密钥大小。 [链接]

密钥大小你用吗?

密钥的最小大小为 128 位,最大大小为 256 位。 [链接]

From MSDN:

PlatformNotSupportedException - There is no supported key size for the current platform. [Link]

What key size do you use?

The minimum size of the key is 128 bits, and the maximum size is 256 bits. [Link]

绅刃 2024-08-09 12:30:57

您的例外情况是:

该平台不支持指定的加密算法

您需要尝试其他加密提供商。并非所有加密提供商都适用于所有系统。 MSDN 有完整的列表。

Your exception states:

The specified cryptographic algorithm is not supported on this platform

You need to try another cryptoprovider. Not all cryptoproviders are available on all systems. MSDN has complete list of those.

早乙女 2024-08-09 12:30:57

您的服务器位于哪里? Microsoft 不允许在世界某些地区(中国、朝鲜等)使用高密钥强度加密。

此外,可以强制执行组策略设置以防止使用某些加密(例如,政府机构要求仅使用 FIPS 算法)通过组策略允许)。

Where is your server located? Microsoft is not allowed to use high key strength crypto in certain areas of the world (china, north korea etc.)

Additionally, there are group policy settings which can be enforced to prevent certain crypto being used (eg governement agency mandates that only FIPS algorithms are allowed via group policy).

卸妝后依然美 2024-08-09 12:30:57

我已经踢掉了 ASP.Net Web 服务并引入了 WCF 服务,现在一切正常。

I've kicked the ASP.Net Web Service and introduced a WCF Service and everything works fine now.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文