var MongoClient = require('../').MongoClient,
  fs = require('fs');

var cert = fs.readFileSync(__dirname + "/client.pem");
var ca = fs.readFileSync(__dirname + "/ca.pem");
var key = fs.readFileSync(__dirname + "/client_password.pem");

var options = {
  server: {
    sslValidate: false,
    sslCert: cert,
    sslKey: cert
  }
}

// var options = { uri_decode_auth: true,
//   db: {},
//   server:
//    { sslCA: '-----BEGIN CERTIFICATE-----\nMIIDmDCCAoCgAwIBAgIDCZNjMA0GCSqGSIb3DQEBBQUAMHUxEjAQBgNVBAMTCWxv\nY2FsaG9zdDEVMBMGA1UECxMMSW50ZWdyYXRpb25zMRAwDgYDVQQKEwdNb25nb0RC\nMRYwFAYDVQQHEw1OZXcgWW9yayBDaXR5MREwDwYDVQQIEwhOZXcgWW9yazELMAkG\nA1UEBhMCVVMwHhcNMTUxMDA1MTgwNzUyWhcNMzUxMDA1MTgwNzUyWjB1MRIwEAYD\nVQQDEwlsb2NhbGhvc3QxFTATBgNVBAsTDEludGVncmF0aW9uczEQMA4GA1UEChMH\nTW9uZ29EQjEWMBQGA1UEBxMNTmV3IFlvcmsgQ2l0eTERMA8GA1UECBMITmV3IFlv\ncmsxCzAJBgNVBAYTAlVTMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA\nhmVxb75ocS+U3gN9YFFVWayHNUX+YbIEt2a/GwBd2IGF+gCtUVZgnQy+Sd1ElDrE\nWO4SesU5zcsSdDdFQTzc73Pd6nyQ68WIr67w+W++EBF4y3ZSpRT8S1kjOWvh4UI4\nenf/hf0eHsrcXZUNS5UfjGmAeXp11OBgc6kFXMrOqvkb8QnA7us1BkJHbLCBc11H\nFUFQNY62J6EZ2AWjYsRRBA8C+5POIdlA4d0rD+4WrqoV/hP7Jry4lNOvRjy8POgR\n0nUu30XNuk33Qew4OvpqbFjxHfyivvrq242BJaj8aZR0KTJx4pNaCTpGexT6JQwg\n1wZ3GtLWg42mWcYUcp7NkwIDAQABozEwLzAMBgNVHRMEBTADAQH/MB8G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EKWy5CTxGkCgYEAzQLu7+CYu5WprHWxuY9i\nfyhVoNVOGyF4fx5A5FUkwfuG3jRxNYXjPcKPirEA+iqrw27aERjg2DB2I4d39OOb\nJsTIF3opNvIcEUSMtwsTec3nRXm1+p9Y2qq1WY/HHdhe05sUkmkKLPaw4/P8oITP\nj1FId1Z+8zqSYE15TfEZm40CgYEAumQvhHBgR7iUoxEf+O5tByiDuv8Uc8qyzynq\n7Ys5AKvuO40Mc2EVJC1JMxcJ4oeARgp9HBiYURdcbAG/uDWkCc2Q+pDgHF+CW6Mr\nTgUxsZv+7uXrZ1ZfpIAH/J+RS0XTH0xQgcSQ+Rfq+KUjW7dAfdt8z0P+E+ei+mOY\nuBVrGUkCgYBsL8E68LZBRjtOfgwJz6lNalkgZdeexcnNiQ9O5qrElRrY8nh2Ds98\nifNsqD3f+fFp0PPSGymqeWl7R7rjCTpUvpuo2bFR7ctpV36cT40enKKq3Sw1sgCb\ngRkQqjjNqYu+tHKXpQbKXh1zKW/o2Hkls+r8H/F3N7q0ujZ8ADbnYw==\n-----END RSA PRIVATE KEY-----' },
//   replSet: { connectWithNoPrimary: true },
//   mongos: {} }

MongoClient.connect('mongodb://localhost:39000/test?ssl=true?', options, function(err) {
  console.dir(err);

})

