I have set up a brand new, clean server to run our asp.net 4 website on. I have copied over the wwwroot folder from one of the existing servers, imported the configuration, and imported pfx file from the "old" server.
Our website contains a shopping cart and during the payment portion of the car开发者_运维技巧t process on this new server it throws the following error:
[CryptographicException: Key not valid for use in specified state.] System.Security.Cryptography.ProtectedData.Unprotect(Byte[] encryptedData, Byte[] optionalEntropy, DataProtectionScope scope) +374 Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.ProtectedKey.Unprotect() +15 Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.SymmetricCryptographer.Decrypt(Byte[] encryptedText) +66 Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.SymmetricAlgorithmProvider.Decrypt(Byte[] ciphertext) +187 Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.Cryptographer.DecryptSymmetric(String symmetricInstance, Byte[] ciphertext) +114 Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.Cryptographer.DecryptSymmetric(String symmetricInstance, String ciphertextBase64) +73 CompanyName.Objects.BasePayment.get_PaymentNumberLastFour() +17 [TargetInvocationException: Property accessor 'PaymentNumberLastFour' on object 'CompanyName.Objects.Payment' threw the following exception:'Key not valid for use in specified state.
The code has not changed, its the same code on the other web server so I'm assuming it has something to do with the machinekeys. I have tried removing the rsa keys from the application data folder but to no avail. I'm not very familiar with cryptography in asp.net so its probably something I'm missing.
Anyone have any ideas?
Thanks.Typically with the encryption process, there is something machine based that makes the key only work on the machine that generated it, even if you are using some kind of third party provider or key.
Try using the following MSDN documentation to export and regenerate the key on your new server.
I wonder if you have to resign your key used for encrypting CC info.
精彩评论