如何在Mongoid 3客户端中启用SSL/TLS?
How do you enable SSL/TLS in the Mongoid 3 client?
我尝试过:
options: -ssl: true但是我得到了"[{"ssl" => true}]:Array(NoMethodError)的未定义方法'each_pair'":
But I get "undefined method `each_pair' for [{"ssl"=>true}]:Array (NoMethodError)":
/home/user1/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/bundler/gems/mongoid-026e32109178/lib/mongoid/config.rb:203:in `options=': undefined method `each_pair' for [{"ssl"=>true}]:Array (NoMethodError) from /home/jwiley/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/bundler/gems/mongoid-026e32109178/lib/mongoid/config.rb:129:in `load_configuration' from /home/jwiley/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/bundler/gems/mongoid-026e32109178/lib/mongoid/config.rb:87:in `load!' from /home/jwiley/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/bundler/gems/mongoid-026e32109178/lib/mongoid.rb:98:in `load!' from /home/jwiley/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/bundler/gems/mongoid-026e32109178/lib/mongoid/railtie.rb:75:in `block in <class:Railtie>'此帖子:
groups.google/forum/#!topic/蒙古包/juexwcPWxOk
...建议您可以通过其配置文件将一些选项添加到Mongoid中以使其实现.但是,尚不清楚到底需要哪些选项以及允许的值是什么.
...Suggests there are options you can feed into Mongoid by it's config file to make it happen. But it's not entirely clear which options are required, and what the allowed values are.
推荐答案配置中不需要连字符.要启用SSL,请使用以下配置:
The hyphen is not needed in the configuration. To enable SSL, use a configuration like this:
production: sessions: default: options: ssl: true关于可用选项,您链接的讨论是关于旧代码的.先前可以在配置中设置SSL证书:
About the available options, the discussion you linked is about an old code. Earlier it was possible to set the SSL certificate in the configuration:
github com/mongoid/moped/blob/dc21475820ff148fb42963752db0bfa6a23f5e1e/lib/moped/sockets/ssl.rb#L95-L125
但是此提交中的代码已删除:
But that code got removed in this commit:
github/mongoid/mopedd7d4f7d4f7d4f7d4e7f4d7e4f7d4e7c diff-d808d724705e7cb8b2e11baf137922af
Mongoid 3随附的Moped版本仅提供主机和端口选项:
And the Moped version which comes with Mongoid 3 has options only for host and port:
https: //github/mongoid/moped/blob/1.5.0-stable/lib/moped/sockets/ssl.rb#L12-L29
更多推荐
如何在Mongoid 3客户端中启用SSL/TLS?
发布评论