I am trying to set up a secret manager in Symfony 5. I followed this Secrets Management Setup course and How to Keep Sensitive Information Secret documentation.
My app is now triggering :
Fatal Error: Maximum execution time of 30 seconds exceeded
Environment variable not found: "DATABASE_URL".
As the documentation says, I dropped DATABASE_URL
from my .env
and used php bin/console secrets:set DATABASE_URL
which output :
[OK] Sodium keys have been generated at "config/secrets/dev/dev.*.public/private.php".
!
! [CAUTION] DO NOT COMMIT THE DECRYPTION KEY FOR THE PROD ENVIRONMENT⚠️
!
[OK] Secret "DATABASE_URL" encrypted in "config/secrets/dev/"; you can commit it.
Here is the result of php bin/console secrets:list
:
// Use "%env(<name>)%" to reference a secret in a config file.
------------------- -------- -------------
Secret Value Local Value
------------------- -------- -------------
DATABASE_URL ******
------------------- -------- -------------
Here how I use %env%
in config/packages/doctrine.yaml
:
doctrine:
dbal:
# ...
url: '%env(DATABASE_URL)%'
# ...
I'm using PHP 7.2.21 and following the documentation :
The Secrets system requires the sodium PHP extension that is bundled with PHP 7.2. If you're using an earlier PHP version, you can install the libsodium PHP extension or use the paragonie/sodium_compat package.
The Symfony console asked me anyway to install paragonie/sodium_compat
polyfill, what I did.
My application isn't working anymore. What am I missing ?
Update #1
It turns out that the problem is from the paragonie/sodium_compat package. The last debug message before Fatal Error: Maximum execution time of 30 seconds exceeded
is :
timeParagonIE_Sodium_Core_Util::mul() vendor/paragonie/sodium_compat/src/Core/Curve25519.php:756
So Symfony isn't able to get the environment variable and trigger the error.
I tried then to decrypt secrets and store them in .env.dev.local
to avoid decrypting them at each request using this command :
php bin/console secrets:decrypt-to-local --force
But Symfony keeps decrypting it and doesn't use .env.dev.local
.