A
A
Andrew2022-02-19 20:27:32
.NET
Andrew, 2022-02-19 20:27:32

How to properly store C# secrets on Linux?

I have an Asp.Net Core web application.
Development in Windows, hosting in Linux
Deployment occurs via FTP directly from the developer's machine to the "combat" server (and subsequent restart of the service).
The application itself runs as a service.

Question: how to store secrets in Linux?
Of.guide suggests storing secrets in the user's folder (from whom the project is launched?). There are doubts about the correctness of this decision.
It seems more correct to be able to pass secrets through the environment variables of the service, but I can not google a way to "merge" these variables and configuration files.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2022-02-19
@byte916

In general, it turned out to be simple
. It is easy to write in the service file
Environment=KEY=VALUE
. At the same time, nested fields are separated by a double underscore
. For example, ConnectionString turns from

{
  "ConnectionStrings": {
    "DefaultConnection": "SomeString"
  }
}

in
Environment=ConnectionStrings__DefaultConnection='SomeString'

Or, use a file with EnvironmentFile variables

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question