title: Mongoose not sending SSL cert to MongoDB server
body: <p>I'm having issues with using some self-signed SSL certificates with Mongoose. The thing that's getting me hung up is that I can connect to the database server just fine with the normal Mongo Node client, but when I try the connection using the exact same configuration with Mongoose.createConnection, I get an error message reading '[conn1] no SSL certificate provided by peer' when I check the Mongod logs.</p>
  
  <p>This is the code I use to connect with the MongoClient.connect (works):</p>
  
  <pre><code>var MongoClient = require('mongodb').MongoClient
  var fs = require('fs')  
  
  // Read the certificates
  const ca = [fs.readFileSync(process.env.caPath)];
  const cert = fs.readFileSync(process.env.certPath);
  let urlPath = ["mongodb://", username, ":", password, "@", dburl, ":", port, "/collection?&amp;ssl=true"]
  let url = urlPath.join('')
  
  // Connect validating the returned certificates from the server
  const options = {
    server: {
      ssl: true,
      sslValidate: true,
      sslCA: ca,
      sslCert: cert
    }
  }
  
  MongoClient.connect(url, options, function(err, db) {
    do stuff
  })
  </code></pre>
  
  <p>And this is the code using Mongoose.createConnection (doesn't work):</p>
  
  <pre><code>const mongoose = require('mongoose');
  const fs = require('fs')
  
  let urlPath = ["mongodb://", username, ":", password "@", dburl, ":", port, "/collection?&amp;ssl=true"]
  let url = urlPath.join('')
  
  var ca = [fs.readFileSync(process.env.caPath, 'utf8')];
  var cert = fs.readFileSync(process.env.certPath, 'utf8');
  
  const options = {
    server: {
      ssl: true,
      sslValidate: true,
      sslCA: ca,
      sslCert: cert
    }
  }
  const connection = mongoose.createConnection(url, options)
  </code></pre>
  
  <p>According to the <a href="http://mongoosejs.com/docs/connections.html" rel="nofollow noreferrer">Mongoose docs</a>, this looks like the right way to connect, and to add to the weirdness, passing in the server options to Mongoose.connect seems to work as well. </p>
  
  <p>Thank you!</p>