1

It is been months but I still do not know how to read my encrypted app.config file using my windows form.

What I want to know is:

How can My WinForm application read a encrypted app.config file?

It always throws this exception

{"Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: The RSA key container could not be opened. (C:\Users\jsumgo\Documents\Visual Studio 2010\Projects\MIPIR\MIPIR\bin\Debug\MIPIR.vshost.exe.Config line 18)"}

I know how to encrypt and decrypt the app.config, but my winform cannot read the values of my connection string.

I use connectionmanager to read my connection string

Here is the code on how I read them

Public password As String = System.Configuration.ConfigurationManager.AppSettings("password")
Public userid As String = System.Configuration.ConfigurationManager.AppSettings("userid")
Public initcat As String = System.Configuration.ConfigurationManager.AppSettings("initcat")
Public dtsrc As String = System.Configuration.ConfigurationManager.AppSettings("dtsrc")

then I build these strings into my connection strings.

I would also like to know the process on how I could deploy this system with a encrypted app.config to my clients.

EDIT: I still cant get RSA to encrypt and read my connection string.

Mr.J
  • 430
  • 2
  • 10
  • 30
  • This may or may not provide anything more than the links provided by @Koder101 but here's [my own example of using protected configuration](http://www.vbforums.com/showthread.php?532768-NET-2-0-Protected-Configuration-(Encrypting-Config-Files)). – jmcilhinney Nov 15 '17 at 04:32
  • Post #2 in that example provides a couple of links I used to read up on the subject. DPAPI is machine specific, so you can't encrypt until the config file is on the target machine, which means doing it as part of the deployment. The alternative is to use the RSA option and encrypt using your own certificate before deployment. – jmcilhinney Nov 15 '17 at 04:36
  • I'll leave my previous comments for reference but, reading your question again, I wonder whether you're already using the RSA option but are not providing the certificate on the machine that needs to perform the decryption. – jmcilhinney Nov 15 '17 at 04:38
  • @jmcilhinney I'm not sure, I know I have encrypted, but when I run my system, It states the error message. – Mr.J Nov 15 '17 at 05:01
  • Follow my example and see if that works for you. It uses DPAPI. Use the links it provides to discern the difference between using DPAPI and RSA. If you've already done that, I don't know what else to tell you. – jmcilhinney Nov 15 '17 at 05:09
  • @jmcilhinney when I click Tools in my VS, It does not show Encrypt Connection strings. – Mr.J Nov 15 '17 at 05:13

0 Answers0