From b244b1661a205bfb7d15d545c8a0178132b2d75d Mon Sep 17 00:00:00 2001 From: Jarom Loveridge Date: Wed, 18 Apr 2018 12:25:46 -0600 Subject: [PATCH] Add additional SSL configuration options. (#25079) http://mongodb.github.io/node-mongodb-native/3.0/api/Server.html --- types/mongoose/index.d.ts | 20 ++++++++++++++++++++ types/mongoose/mongoose-tests.ts | 19 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index d8ffa046e9..723a88bdf8 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -326,6 +326,26 @@ declare module "mongoose" { /** How long driver keeps waiting for servers to come back up (default: Number.MAX_VALUE) */ bufferMaxEntries?: number; + /** additional SSL configuration options */ + /** Array of valid certificates either as Buffers or Strings */ + sslCA?: ReadonlyArray; + /** Array of revocation certificates either as Buffers or Strings (needs to have a mongod server with ssl support, 2.4 or higher) */ + sslCRL?: ReadonlyArray; + /** SSL certificate */ + sslCert?: Buffer | string; + /** SSL private key */ + sslKey?: Buffer | string; + /** SSL Certificate pass phrase */ + sslPass?: Buffer | string; + /** Default: true; Server identity checking during SSL */ + checkServerIdentity?: boolean | Function; + /** String containing the server name requested via TLS SNI. */ + servername?: string; + + /** Passed directly through to tls.createSecureContext. See https://nodejs.org/dist/latest-v9.x/docs/api/tls.html#tls_tls_createsecurecontext_options for more info. */ + ciphers?: string; + ecdhCurve?: string; + // TODO safe?: any; fsync?: any; diff --git a/types/mongoose/mongoose-tests.ts b/types/mongoose/mongoose-tests.ts index 244658ac9b..d6fbe3cd82 100644 --- a/types/mongoose/mongoose-tests.ts +++ b/types/mongoose/mongoose-tests.ts @@ -65,6 +65,25 @@ mongoose.Types.ObjectId; mongoose.Types.Decimal128; mongoose.version.toLowerCase(); +const sslConnections: {[key: string]: mongoose.Connection} = { + basic: mongoose.createConnection(connectUri, {ssl: true}), + customCA: mongoose.createConnection( + connectUri, + { + ssl: true, + sslCA: [new Buffer('ca string')], + sslCRL: [new Buffer('crl buffer')], + sslCert: 'ssl cert', + sslKey: new Buffer('ssl private key'), + sslPass: 'ssl password', + servername: 'localhost', + checkServerIdentity: true, + ciphers: 'ciphers', + ecdhCurve: 'ecdhCurve', + } + ), +}; + /* * section collection.js * http://mongoosejs.com/docs/api.html#collection-js