System.PlatformNotSupportedException AesCryptoServiceProvider
我有以下问题。
我创建了一个使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
来自 MSDN:
密钥大小你用吗?
From MSDN:
What key size do you use?
您的例外情况是:
您需要尝试其他加密提供商。并非所有加密提供商都适用于所有系统。 MSDN 有完整的列表。
Your exception states:
You need to try another cryptoprovider. Not all cryptoproviders are available on all systems. MSDN has complete list of those.
您的服务器位于哪里? 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).
我已经踢掉了 ASP.Net Web 服务并引入了 WCF 服务,现在一切正常。
I've kicked the ASP.Net Web Service and introduced a WCF Service and everything works fine now.