Click here to Skip to main content
15,887,585 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello folks,
I have the following question:
In my ASP.NET MVC application I want to store some key/value settings in my database.
Some of this key/value settings contain passwords, that I want to encrypt to secure them.

I can´t hash the passwords because I need some passwords to autheticate on a remote SMTP server.

On MSDN I found an article about securing configuration settings with "Protected Configuration Providers", but I don´t want to store that settings in my web.config file.

I considered to use the DpapiProtectedConfigurationProvider that uses some machine and user specific properties as encryption keys, but this provider is built to work only with XML configuration nodes.

So, what is the best method to store passwords in an C# application?

greetings
Posted

_-_nox_-_ wrote:
I need the decrypted password to authenticate on the remote SMTP server


No, you don't.
Create single user to allow access to SMTP server via your application. Provide authentication to your application and use default user to operate on SMTP server. Log user activity.

That's all!

As Sergey mentioned, do not store encrypted/decrypted passwords in your application to log in into SMTP server.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 7-May-14 12:28pm    
Agree, a 5.
—SA
Maciej Los 7-May-14 12:29pm    
Thank you, Sergey ;)
Nico Haslberger 7-May-14 15:47pm    
Ok, but what is the best way to store the credentials of my SMTP server?
Maciej Los 7-May-14 16:03pm    
Search for "Resources" ;)
Nico Haslberger 7-May-14 16:22pm    
Thank you, but I don´t want to use several configuration files. There must be a possibility to store the password the encryption key in a safe way...
You should not store any passwords, even encrypted, this is not absolutely not needed for authentication.

Feel disagree? Surprised? Then keep reading. Please see my past answers:
i already encrypt my password but when i log in it gives me an error. how can decrypte it[^],
Decryption of Encrypted Password[^],
storing password value int sql server with secure way[^].

Are you getting the idea? You need to store cryptographic hash function of passwords, and always compare hash with hash. Then no one will be able to learn the original passwords, no matter how much access this person may have.

—SA
 
Share this answer
 
Comments
Maciej Los 7-May-14 11:34am    
Sure, a 5!
Nico Haslberger 7-May-14 11:44am    
Thank you for your reply, but I need the decrypted password to authenticate on the remote SMTP server, as I wrote in my question.
The end user in our system has no IT knowledge and should not have to enter or keep a password of an smtp server.
greetings
Maciej Los 7-May-14 12:25pm    
Wrong! Please, see my answer.
Sergey Alexandrovich Kryukov 7-May-14 12:27pm    
No, you don't need it. And this was not just reply, but an answer. :-)
—SA
Sergey Alexandrovich Kryukov 7-May-14 12:27pm    
Thank you, Maciej.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900