I'm currently working on a ASP.NET Core application, where part of it is a 'EmailService' Now, it's only function is to send informative emails via. SMTP, using the clients own credentials however. And I'm quite uncertain as to how I should handle storage of these credentials, to enable SMTP, it needs:
- server address
- Port
- mail address
- password
all but the password, i suppose could be safely stored in the database, but how do I go about storing the password?
(The database is NOT stored on the same machine, if that makes any sort of a difference)
As stated there are several ways of handling this.
The solution I picked was using .NET Core built in stuff from
Microsoft.AspNetCore.DataProtectionby doing.AddDataProtection()on the service collection so it can be accessed through DI.This is done in a controller by:
It supports a lot of different key configuration, and I'd recommend using this with .NET Core.