Frage

How do you enable SSL/TLS in the Mongoid 3 client?

I've tried:

options:
  -ssl: true

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>'

This post:

https://groups.google.com/forum/#!topic/mongoid/juexwcPWxOk

...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.

War es hilfreich?

Lösung

The hyphen is not needed in the configuration. To enable SSL, use a configuration like this:

production:
  sessions:
    default:
      options:
        ssl: true

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:

https://github.com/mongoid/moped/blob/dc21475820ff148fb42963752db0bfa6a23f5e1e/lib/moped/sockets/ssl.rb#L95-L125

But that code got removed in this commit:

https://github.com/mongoid/moped/commit/ace43c4d7e4bbe7d32dfcf1f7ac5ee34e47647c9#diff-d808d724705e7cb8b2e11baf137922af

And the Moped version which comes with Mongoid 3 has options only for host and port:

https://github.com/mongoid/moped/blob/1.5.0-stable/lib/moped/sockets/ssl.rb#L12-L29

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top