1
// Test passwords on private keys for SSL
2
// This tests that providing a proper password works and that providing no password or incorrect
3
// password fails. It uses both mongod and mongo to run the tests, since the mongod binary
4
// does not return error statuses to indicate an error.
5
port = allocatePorts( 1 )[ 0 ];
6
var baseName = "jstests_ssl_ssl_cert_password";
7
var dbpath = "/data/db/" + baseName;
10
// Password is correct
11
md = startMongod("--nopreallocj",
15
"--sslPEMKeyFile", "jstests/libs/password_protected.pem",
16
"--sslPEMKeyPassword", "qwerty");
17
// startMongod connects a Mongo shell, so if we get here, the test is successful.
22
// Password missing; error logged is:
23
// error:0907B068:PEM routines:PEM_READ_BIO_PRIVATEKEY:bad password read
24
var md = runMongoProgram("mongo", "--port", port,
26
"--sslPEMKeyFile", "jstests/libs/password_protected.pem");
28
// 1 is the exit code for failure
33
// Password incorrect; error logged is:
34
// error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt
35
md = runMongoProgram("mongo", "--port", port,
37
"--sslPEMKeyFile", "jstests/libs/password_protected.pem",
38
"--sslPEMKeyPassword", "barf");
40
// 1 is the exit code for failure
46
var exitCode = stopMongod(port, 15);
47
assert(exitCode == 0);