title: Mongo SSL config with CA cert only works for rails console, not rails server
body: <p>I am trying to configure a Rails 4.2.6 app to connect over SSL to a MongoDB cluster on compose.io. The app uses the mongo 2.4.1 and mongoid 5.1.5 gems. Compose.io MongoDB clusters use self-signed SSL certificates so I downloaded the CA certificate from compose.io and placed it in <code>lib/certs/mongo-ca-bundle.pem</code>.</p>
  
  <p>My mongoid.yml file looks like this (redacted):</p>
  
  <pre><code>development:
    clients:
      default:
        uri: mongodb://myuser:mypassword@some-host.dblayer.com:1111,some-other-host.dblayer.com:2222/mydb?ssl=true
        options:
          ssl_ca_cert: /path/to/myapp/lib/certs/mongo-ca-bundle.pem
  </code></pre>
  
  <p>The above configuration works perfectly when I run <code>rails console</code> and I can successfully run queries against collections in the compose.io database.</p>
  
  <p>However, when I try to run <code>rails server</code> it crashes after 30 seconds with a "No server is available" error message:</p>
  
  <pre><code>[..]/mongo/server_selector/selectable.rb:115:in `select_server': No server is available matching preference: #&lt;Mongo::ServerSelector::Primary:0x47167439625640 tag_sets=[] max_staleness=nil&gt; using server_selection_timeout=30 and local_threshold=0.015 (Mongo::Error::NoServerAvailable)
  [..]/mongo/cluster.rb:226:in `next_primary'
  </code></pre>
  
  <p>When I enable debug logging for mongoid it indicates that the problem is with the SSL handshake:</p>
  
  <pre><code>DEBUG -- : MONGODB | Server some-host.dblayer.com:1111 initializing.
  DEBUG -- : MONGODB | SSL handshake failed. MongoDB may not be configured with SSL support.
  </code></pre>
  
  <p>I used to get the same error in the rails console until I added the <code>ssl_ca_cert</code> configuration. I did manage to get the server to connect by specifying <code>ssl_verify: false</code> but I don't consider that a valid workaround. How can I fix this? How come the console works but the server doesn't?</p>