ruby-on-rails - PRNG 未播种错误

标签 ruby-on-rails ruby openssl prng

我收到一个间歇性错误,指出在尝试生成表单例份验证 token 时伪随机数生成器未播种。我已经复制了下面堆栈跟踪的相关部分。

这是我所知道/看到的: - 重启 passenger 似乎暂时解决了这个问题 - 从控制台运行相同的代码按预期工作 -/dev/urandom 存在所以它应该能够使用它来播种 - 这发生在 ubuntu 10.04 上,openssl 0.9.8k,ree 1.8.7 p253 和 passenger 3.0.3。 - 我已经读到关于 unicorn 的一个问题,听起来有点像重新启动 worker 时发生的问题,但没有看到 passenger 上描述的类似内容。

SessionsController#new (ActionView::TemplateError) "PRNG not seeded"
/usr/local/lib/ruby/1.8/securerandom.rb:53:in `random_bytes'
/usr/local/lib/ruby/1.8/securerandom.rb:53:in `random_bytes'
/usr/local/lib/ruby/1.8/securerandom.rb:105:in `base64'
vendor/bundle/ruby/1.8/gems/actionpack-2.3.14/lib/action_controller/request_forgery_protection.rb:109:in `form_authenticity_token'
(eval):2:in `send'
(eval):2:in `form_authenticity_token'

非常难过。非常感谢任何帮助。

最佳答案

假设 /dev/random/dev/urandom 都是可读/可写的并且您仍然收到此错误,也许您需要运行/安装一个熵生成器像 prngd 吗?

尝试:

 $ sudo /etc/init.d/prngd start

如果失败,请先安装 prngd:

 $ sudo apt-get install prngd

关于ruby-on-rails - PRNG 未播种错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11382600/

相关文章:

ruby-on-rails - 安装 gems 时停止询问密码

ruby-on-rails - 允许在 Rails 7.1 中使用带有新清理程序的 ActionText 标记

php - Ruby 与 PHP 中 'or' 条件的处理

ruby-on-rails - 带有 Carrierwave 的动态 uploader

Ruby:从阿拉伯字符解析日期?

ruby-on-rails - Tire/ElasticSearch 单表继承支持

Python pyopenssl 签名证书错误(Firefox : SEC_ERROR_REUSED_ISSUER_AND_SERIAL, chrome:ERR_CERT_AUTHORITY_INVALID)

c++ - 使用openssl解析加密文件

php - OPENSSL file_get_contents() : Failed to enable crypto

ruby-on-rails - Ruby on Rails i18n - 想要翻译模型中的自定义消息