Decrypt encrypted key using Certificate not working in .NET but works in SOAP UI

I'm trying to figure out why I can't seem to decrypt an encrypted key from .NET with a X509 Certificate.  

.NET Code
encryptedKey = "jW3VDsUZWIdzfZ1bPN3iKI2Pf9u22kUax0DFnF3A9H+nvcBQuVC2efw1FYGm5/AvnN27kXqA4PyCqcQLp/tguVqHtzdR7mJtkTCyY8TUoAej2Mqzv2uiEKULB/8rlPDl2DOkSMGJqieenAG/7gZjWhlU0eYrlcMi5dtAnPFTfy+LvtJ6bbGEDgy4FhoT49T6sO0kjBJHp5YI0p/CeEuc+WMT/BMGG1YuDPswltj0VzeaE3KbHSLvJPjGCQ3U0YkUWm8h9zM22S/mRvfMhEu1aRdQpojGUiSLKUJyotNu8fRulKeB1TVuE7AlDGrbAUsRtU+y6PdLMcEHW+BRq5Uouw==";

var encryptedKeyByte = Convert.FromBase64String(encryptedKey);

var clientCert = new X509Certificate2(@"C:\certificates\xxxxx.pfx", "xxxx");
var rsa = (RSACryptoServiceProvider)clientCert.PrivateKey;
byte[] key = rsa.Decrypt(encryptedKeyByte, false);

Open in new window


The error I get when I try to run the last line of the code rsa.Decrypt(encryptedKeyByte, false)
The parameter is incorrect.


In SOAP UI the decryption works where I use the same certificate.  I just had to convert the file pfx to a jks file to get it working in SOAP UI.  But other than that the settings look the same to me.
Here is a screen shot of the SOAP UI settings.  I'm guessing the Signature Keystore in the SOAP UI seetings is not used for the decryption process.  The Decrypt Keystore settings in SOAP UI is the one I'm using in .NET.  Only in .NET its a pfx file.  
SOAP UI Settings
I also imported the certificate to my local box to see some of the details.  Here is what I see:
Certificate seen in MMCcertificate_properties_in_mmc_2.pngCertificate seen in MMC
Please let me know if you need me to provide any other information or need me to test something out.  Thanks in advance for your help.
LVL 1
HItesh RanaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kyle SantosCustomer RelationsCommented:
Hi,

I am following up on your question.  Do you still need help?

If you solved the problem on your own, would you please post the solution here in case others have the same problem?

Regards,

Kyle Santos
Customer Relations
0
HItesh RanaAuthor Commented:
I'm sorry for the late response.  I was not able to solve the issue yet.   Yes.  I still need help. Do you have any ideas?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.