Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-810

Connecting to Mongod via Ruby driver using SSL returns Mongo::ConnectionFailure

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 12_01_17
    • Affects Version/s: 1.11.1
    • Component/s: Public API
    • None
    • Environment:
      Ubuntu 14.04.1 LTS (GNU/Linux 3.15.4-x86_64-linode45 x86_64)
    • 1

      I built mongodb 2.6.4 with SSL enabled from source following the official build documentation, and got mongod running fine on a newly provisioned Linux server.

      I used a self-signed certificate and configured mongod as described in the Configure SSL docs. The key post of my config is:

      ...
      net:
         bindIp: 127.0.0.1
         port: 27017
         ssl:
            mode: requireSSL
            PEMKeyFile: /opt/mongo/security/mongodb.pem
      ... 
      

      To test I tried running mongo client with --ssl and I got the client console. Also I tried without the --ssl argument and connection was declined.

      Next was connecting with the Ruby Driver. I installed 'mongo' gem and the installed version was v1.11.1. I used the following program derived from SSL Configuration for Clients sample:

      require 'rubygems'
      require 'mongo'
      client = Mongo::MongoClient.new('localhost', 27017, {:ssl => true})
      

      But when I run all I get is:

      /home/test/.rvm/gems/ruby-1.9.3-p547/gems/mongo-1.11.1/lib/mongo/mongo_client.rb:422:in `connect': Failed to connect to a master node at localhost:27017 (Mongo::ConnectionFailure)
      from /home/test/.rvm/gems/ruby-1.9.3-p547/gems/mongo-1.11.1/lib/mongo/mongo_client.rb:661:in `setup'
      from /home/test/.rvm/gems/ruby-1.9.3-p547/gems/mongo-1.11.1/lib/mongo/mongo_client.rb:177:in `initialize'
      from test_mongo_ssl.rb:8:in `new'
      from test_mongo_ssl.rb:8:in `<main>'
      

      As an experiment I also tried connecting using the Python driver:

      from pymongo import MongoClient
      c = MongoClient(host="localhost", port=27017, ssl=True)
      

      And that connected fine. Therefore I am reaching the conclusion that there is an issue specifically with the Ruby driver. Or the driver's documentation doesn't accurately describe how one should connect to mongod with ssl enabled.

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            arooaroo Andrew Roberts
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: