Secure handling of sensitive configuration values (SQL connection strings and agent tokens)
1 vote
Currently, sensitive configuration values such as SQL Server connection strings and agent tokens need to be stored in plaintext or provided through environment variables.
For on-premises installations running PowerShell Universal directly on Windows Server, environment variables don't really solve the problem. They mainly move the plaintext secret from the configuration file to another location.
It would be useful to have a native and supported mechanism for securely storing or referencing sensitive configuration values.
Possible approaches could include:
Encrypted/protected values in appsettings.json and agents.json
Integration with a secure secret store or Windows-native credential mechanism
Support for referencing secrets instead of storing the actual value in the configuration
Certificate-based authentication (mTLS) for PSU agents as an alternative to static app tokens
The goal would be to avoid having long-lived credentials or tokens stored in plaintext on the server while still having a solution that works well for traditional on-premises Windows Server deployments.
I agree that environment variables alone don’t eliminate the plaintext-secret concern.
For agent tokens, you can reference a PowerShell SecretManagement vault instead of putting the token in agent.json. For Devolutions Agent:
{
"PsuAgent": {
"Enabled": true,
"ServerUrl": "https://psu.example.com:5006",
"AgentId": "agent-01",
"AppToken": "$secret:psu-agent-token"
}
}
The older Event Hub agent also supports the reference in its Connections entry. The vault and its extension must be available to the agent’s service account and accessible without an interactive prompt. The token is still needed at runtime, so vault access and token rotation remain important. See the agent guide.
For SQL Server, $Secret: is not currently expanded in Data:ConnectionString. On Windows, an alternative is integrated authentication using the PSU service account, potentially a gMSA:
{
"Data": {
"ConnectionString": "Server=sql.example.com;Database=PSU;Integrated Security=True;Encrypt=True;TrustServerCertificate=False"
}
}
The service identity needs the appropriate SQL permissions, and the SQL Server certificate must be trusted and match the hostname. See the persistence guide.
Broader secret-reference support for connection strings and an mTLS alternative for agents are both useful suggestions. I'll open an issue to track this and let you know when we implement it more completely.
Adam Driscoll
PowerShell Expert and Software Architect at Devolutions
Hi @Adam Driscoll,
Thanks for the quick reply and the detailed information.
I'm aware of the option to use the PowerShell SecretManagement module for agent tokens. My concern is that the referenced documentation dates back to 2022 and is, according to the documentation, no longer being updated. Because of that, I'd prefer not to rely on this approach for a new implementation if possible.
The older Event Hub agent isn't something we need, so that's not relevant for our use case.
Regarding the SQL connection string, Integrated Security unfortunately isn't an option for us. We have company requirements we need to follow, and our databases are provided by an external service provider. As a result, I don't have any influence over the authentication method used for the database connection.
So having native support for securely referencing secrets in the connection string would be very helpful for our environment.
Thanks again for looking into this and for opening an issue to track it.