Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Where should I store credentials

Where should I store credentials

Scheduled Pinned Locked Moved C#
sysadminquestion
11 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Nico Haslberger

    Hello folks, I want to store login credentials for a SMTP server which should be stored encrypted. In your opinion: Where should I store the credentials? How they should be secured? Why do you think should I use your suggestion? greetings Nico

    D Offline
    D Offline
    Deepanshu Goel
    wrote on last edited by
    #2

    Hi Nico, You can store the credentials in SQL Database. They can be secured by using Hash encryption (one way encryption).

    P N 2 Replies Last reply
    0
    • N Nico Haslberger

      Hello folks, I want to store login credentials for a SMTP server which should be stored encrypted. In your opinion: Where should I store the credentials? How they should be secured? Why do you think should I use your suggestion? greetings Nico

      B Offline
      B Offline
      Bernhard Hiller
      wrote on last edited by
      #3

      I guess it is your application which tries to communicate with the SMTP server. Hence the application must be able to retireve the clear text password when connecting to the server. Consequently, you cannot hash the password, but you must encrypt it. This also adds the question of how to store the key and the salt value. Next question is: who configures your application? Is it the "user" who enters his personal SMTP credentials or is it an administrator of the user's company who does so (and applies the same configuration to all installations of the application in the company)? Depending on the answer, you may use a user-specific settings file, a program specific settings file, the *.exe.config file, store data in a database, etc... Also note that the .exe.config file contains a connectionStrings section, which can be "automatically" encrypted and also used for this purpose.

      N 1 Reply Last reply
      0
      • D Deepanshu Goel

        Hi Nico, You can store the credentials in SQL Database. They can be secured by using Hash encryption (one way encryption).

        P Offline
        P Offline
        Peter_in_2780
        wrote on last edited by
        #4

        That won't work. See Bernard's message below for why it won't. Cheers, Peter

        Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012

        1 Reply Last reply
        0
        • D Deepanshu Goel

          Hi Nico, You can store the credentials in SQL Database. They can be secured by using Hash encryption (one way encryption).

          N Offline
          N Offline
          Nico Haslberger
          wrote on last edited by
          #5

          Right that won´t work.

          1 Reply Last reply
          0
          • B Bernhard Hiller

            I guess it is your application which tries to communicate with the SMTP server. Hence the application must be able to retireve the clear text password when connecting to the server. Consequently, you cannot hash the password, but you must encrypt it. This also adds the question of how to store the key and the salt value. Next question is: who configures your application? Is it the "user" who enters his personal SMTP credentials or is it an administrator of the user's company who does so (and applies the same configuration to all installations of the application in the company)? Depending on the answer, you may use a user-specific settings file, a program specific settings file, the *.exe.config file, store data in a database, etc... Also note that the .exe.config file contains a connectionStrings section, which can be "automatically" encrypted and also used for this purpose.

            N Offline
            N Offline
            Nico Haslberger
            wrote on last edited by
            #6

            Hello Bernhard, thank you for your reply! The SMTP credentials are configured by an Administrator and not by the end user, so the SMTP is a global SMTP. Ok, and in case of an ASP.NET application, this would be the web.config, wouldn´t it be? To secure the configuration section would this be the appropriate way?

            greetings Nico

            B 1 Reply Last reply
            0
            • N Nico Haslberger

              Hello Bernhard, thank you for your reply! The SMTP credentials are configured by an Administrator and not by the end user, so the SMTP is a global SMTP. Ok, and in case of an ASP.NET application, this would be the web.config, wouldn´t it be? To secure the configuration section would this be the appropriate way?

              greetings Nico

              B Offline
              B Offline
              Bernhard Hiller
              wrote on last edited by
              #7

              You identified the right section for web.config. I'd suggest to enter the credentials and do the protection during the deployment of the application.

              1 Reply Last reply
              0
              • N Nico Haslberger

                Hello folks, I want to store login credentials for a SMTP server which should be stored encrypted. In your opinion: Where should I store the credentials? How they should be secured? Why do you think should I use your suggestion? greetings Nico

                I Offline
                I Offline
                ianderf
                wrote on last edited by
                #8

                Use the System.Security.Cryptography.ProtectedData class. It's designed for exactly this task.

                N M 2 Replies Last reply
                0
                • I ianderf

                  Use the System.Security.Cryptography.ProtectedData class. It's designed for exactly this task.

                  N Offline
                  N Offline
                  Nico Haslberger
                  wrote on last edited by
                  #9

                  Thank you for your reply, but isn´t this class´ purpose only for encrypting and decrypting data with the dapi mechanism?

                  I 1 Reply Last reply
                  0
                  • N Nico Haslberger

                    Thank you for your reply, but isn´t this class´ purpose only for encrypting and decrypting data with the dapi mechanism?

                    I Offline
                    I Offline
                    ianderf
                    wrote on last edited by
                    #10

                    It is. You need to decide yourself, where to store encrypted data - config, settings file, etc.

                    1 Reply Last reply
                    0
                    • I ianderf

                      Use the System.Security.Cryptography.ProtectedData class. It's designed for exactly this task.

                      M Offline
                      M Offline
                      Matty22
                      wrote on last edited by
                      #11

                      Yeah DataProtection api is the way to go

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups