php
system_error
ai_generated
true
Warning: openssl_random_pseudo_bytes(): Seed could not be generated in /var/www/app/src/Security/TokenGenerator.php on line 23
ID: php/openssl-random-pseudo-bytes-seed
80%Fix Rate
82%Confidence
1Evidence
2023-09-25First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| PHP 7.4 | active | — | — | — |
| PHP 8.0 | active | — | — | — |
| PHP 8.1 | active | — | — | — |
| PHP 8.2 | active | — | — | — |
Root Cause
The OpenSSL random number generator cannot gather enough entropy to seed, typically due to a missing or empty /dev/urandom on the system, or a restrictive open_basedir configuration.
generic中文
OpenSSL 随机数生成器无法收集足够的熵来播种,通常是由于系统中缺少或空的 /dev/urandom,或受限制的 open_basedir 配置。
Official Documentation
https://www.php.net/manual/en/function.openssl-random-pseudo-bytes.phpWorkarounds
-
80% success Check if /dev/urandom exists and is readable: `ls -la /dev/urandom`. If missing, create it: `sudo mknod -m 644 /dev/urandom c 1 9 && sudo chmod 644 /dev/urandom`. Then restart PHP-FPM.
Check if /dev/urandom exists and is readable: `ls -la /dev/urandom`. If missing, create it: `sudo mknod -m 644 /dev/urandom c 1 9 && sudo chmod 644 /dev/urandom`. Then restart PHP-FPM.
-
85% success If in a Docker container, ensure the container has access to the host's entropy pool by adding `--privileged` or mounting `/dev/urandom` from the host: `docker run -v /dev/urandom:/dev/urandom ...`
If in a Docker container, ensure the container has access to the host's entropy pool by adding `--privileged` or mounting `/dev/urandom` from the host: `docker run -v /dev/urandom:/dev/urandom ...`
中文步骤
Check if /dev/urandom exists and is readable: `ls -la /dev/urandom`. If missing, create it: `sudo mknod -m 644 /dev/urandom c 1 9 && sudo chmod 644 /dev/urandom`. Then restart PHP-FPM.
If in a Docker container, ensure the container has access to the host's entropy pool by adding `--privileged` or mounting `/dev/urandom` from the host: `docker run -v /dev/urandom:/dev/urandom ...`
Dead Ends
Common approaches that don't work:
-
Increasing PHP's memory_limit or max_execution_time hoping the random generation will complete
95% fail
The error is about entropy availability, not memory or time; the system simply cannot gather enough random data.
-
Installing haveged or rng-tools without verifying they are actually running and providing entropy
60% fail
The service might be installed but not started, or the entropy source might be blocked by virtualization or container restrictions.