0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-27 23:27:11 +01:00
mongodb/jstests/ssl/ssl_private_key.js
W. Brad Moore 3cbd53553c SERVER-84397: Use proper SSL options in tests
GitOrigin-RevId: 2ceb3b5faa6e0038e0f6d2f4326241b735b83535
2024-02-01 15:32:18 +00:00

34 lines
1.1 KiB
JavaScript

// Test that clients support "BEGIN PRIVATE KEY" pems with RSA keys
const SERVER_CERT = "jstests/libs/server.pem";
const CA_CERT = "jstests/libs/ca.pem";
const CLIENT_CERT = "jstests/libs/client_privatekey.pem";
function authAndTest(port) {
const mongo = runMongoProgram("mongo",
"--host",
"localhost",
"--port",
port,
"--tls",
"--tlsCAFile",
CA_CERT,
"--tlsCertificateKeyFile",
CLIENT_CERT,
"--eval",
"1");
// runMongoProgram returns 0 on success
assert.eq(0, mongo, "Connection attempt failed");
}
const x509_options = {
tlsMode: "requireTLS",
tlsCertificateKeyFile: SERVER_CERT,
tlsCAFile: CA_CERT
};
let mongo = MongoRunner.runMongod(Object.merge(x509_options, {auth: ""}));
authAndTest(mongo.port);
MongoRunner.stopMongod(mongo);