【发布时间】:2017-01-31 08:12:59
【问题描述】:
我是 C# 新手。我不明白为什么它会产生问题。
CspParameters cspParams = new CspParameters(24);
cspParams.KeyContainerName = "XML_DISG_RSA_KEY";
RSACryptoServiceProvider key = new RSACryptoServiceProvider(cspParams);
以下代码在我的本地设置中运行良好。但它不能在客户端工作。
他们得到了以下异常。
[CryptographicException:密钥在指定状态下无效。 ]
System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer) +4644432
System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType, CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle) +69
System.Security.Cryptography.RSACryptoServiceProvider.GetKeyPair() +92
System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize, CspParameters parameters, Boolean useDefaultKeySize) +173
System.Security.Cryptography.RSACryptoServiceProvider..ctor(CspParameters parameters) +14
你能帮帮我吗?
【问题讨论】: