Skip to content

Knowledgebase

Using Symfony secrets on a hosting server

development, servers

Symfony can keep sensitive configuration in an encrypted secrets vault. The encrypted files and their production decryption key have different access requirements and must be handled separately.

What you need before you begin

Confirm the application uses Symfony secrets and has the required Sodium extension. Identify the production vault and the deployment mechanism that supplies its decryption capability.

01 Use Symfony secrets on a hosting server

  1. Generate or maintain the vault through the documented console workflow in a controlled environment. Select the production vault explicitly using the environment mechanism required by your Symfony branch, including APP_RUNTIME_ENV where applicable.

  2. Add the required secret values without writing them into a shell command that will be logged. Keep the production decryption key out of the repository and ordinary build artifacts.

  3. Deliver the decryption key through protected runtime configuration or the documented protected key file. Restrict access to the account that needs it.

  4. Check for real environment variables with the same names. An environment value can override the vault value, making an apparently successful secret update ineffective.

  5. Test a feature that consumes the secret and document rotation and recovery. Remove temporary copies used during deployment.

Confirm the expected result

Verify that the intended service can authenticate without revealing the secret. Confirm the production key is absent from public directories, repository history and downloadable deployment archives.

Troubleshoot unexpected results

If decryption fails, check the selected vault, key and runtime environment. If an old value persists, inspect environment overrides before regenerating keys or replacing the encrypted vault.

A common question

Should the CI system receive every production secret?

Only give a build or deployment stage the access it actually needs. Symfony can compile its container without revealing every secret, so broad secret access should not be assumed necessary.

Sources and further reading

Was this answer helpful?

Need a little more help?

Our support team can help you find the next step.

Contact support