如何在Mongoid 3客户端中启用SSL / TLS?
我试过了:
options:
-ssl: true
但是我得到了未定义的方法`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>'
这篇文章:
https://groups.google.com/forum/#!topic/mongoid/juexwcPWxOk
...建议您可以通过它的配置文件为Mongoid提供选项以实现它。但是,并不完全清楚需要哪些选项,以及允许的值是什么。
答案 0 :(得分:2)
配置中不需要连字符。要启用SSL,请使用以下配置:
production:
sessions:
default:
options:
ssl: true
关于可用选项,您链接的讨论是关于旧代码的。之前可以在配置中设置SSL证书:
但是在此提交中删除了该代码:
Mongoid 3附带的Moped版本只有主机和端口选项:
https://github.com/mongoid/moped/blob/1.5.0-stable/lib/moped/sockets/ssl.rb#L12-L29