Skip to content

Instantly share code, notes, and snippets.

@TylerBrock
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TylerBrock/c47c094bd93382a691a7 to your computer and use it in GitHub Desktop.
Save TylerBrock/c47c094bd93382a691a7 to your computer and use it in GitHub Desktop.
MongoDB C++ Driver SSL example
#include "mongo/util/net/ssl_options.h"
#include "mongo/client/init.h"
int main() {
sslGlobalParams.sslMode.store(SSLGlobalParams::SSLMode_requireSSL);
// only really need a PEM on the server side
mongo::sslGlobalParams.sslPEMKeyFile = "<path/to/keyfile.pem>";
mongo::Status status = mongo::client::initialize();
if (!status.isOK())
::abort();
DBClientConnection c;
c.connect("hostname.whatever.com"); // outgoing connections are SSL
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment