如何在Mongoid 3客户端中启用SSL/TLS?

编程入门 行业动态 更新时间:2024-10-28 01:18:52
本文介绍了如何在Mongoid 3客户端中启用SSL/TLS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何在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?

本文发布于:2023-11-05 07:14:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1560230.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:客户端   如何在   TLS   Mongoid   SSL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!