Skip to content

Configuring the 26Compat Driver

Tyler Brock edited this page Aug 29, 2014 · 3 revisions

Configure SSL on the 26compat driver 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
}
Clone this wiki locally