Add additional SSL configuration options. (#25079)

http://mongodb.github.io/node-mongodb-native/3.0/api/Server.html
This commit is contained in:
Jarom Loveridge
2018-04-18 11:25:46 -07:00
committed by Ryan Cavanaugh
parent a8de5cf374
commit b244b1661a
2 changed files with 39 additions and 0 deletions
+20
View File
@@ -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<Buffer | string>;
/** Array of revocation certificates either as Buffers or Strings (needs to have a mongod server with ssl support, 2.4 or higher) */
sslCRL?: ReadonlyArray<Buffer | string>;
/** 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;
+19
View File
@@ -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