I have a .NET core console application (not ASP.NET core) that uses a .NET Standard 2.0 class library.
I have a JSON configuration file that gets read out by the class library to setup something dynamically.
The application normally runs under the user that started the process (CredentialCache.DefaultNetworkCredentials) as scheduled task. But it is sometimes necessary that it should run under another account of a different user, for example to connect to an external system.
Of course I don't want to store the username and password (unencrypted) in the configuration. But what are my options. If I use a key, the key must be stored somewhere too, so it wouldn't be really secure.
I searched the web but haven't found a solution. I guess maybe the credential could be stored in the user or machine config instead of the json config? But I don't know if .NET core has access to this classes and the app should also work on other operating systems (like linux), that have the .NET core runtime installed.
Does anyone know a solution for this?