Introduction
By default, FileCloud connects to a MongoDB server in plain text mode, but FileCloud can be enabled to connect to MongoDB server in SSL mode.
Enabling SSL Mode Connection
-
To enable SSL based connection to MongoDB server, edit the file WWWROOT/core/framework/slmongoclientcontext.class.php and replace the contents of the file with the following:
Mongo Client
PHP<?php /* * Copyright(c) 2015 CodeLathe LLC. All rights Reserved. * This file is part of Tonido FileCloud http://www.tonido.com */ namespace core\framework; defined('TONIDO_CLOUD_ROOT_DIR') or exit('Forbidden'); /** * Description of slmongoclientcontext * * @author madhan */ class SLMongoClientContext{ public static $USECONTEXT = TRUE; public static function getOptions(){ return array("ssl" => true); } public static function getContext(){ //$SSL_DIR = "c:\\xampp\\mongodb\\bin\\certs"; //$SSL_FILE = "CA_Root_Certificate.pem"; $ctx = stream_context_create(array( "ssl" => array( /* Certificate Authority the remote server certificate must be signed by */ //"cafile" => $SSL_DIR . DIRECTORY_SEPARATOR . $SSL_FILE, "local_cert" => "c:\\xampp\\mongodb\\bin\\certs\\mongodb.pem", /* Disable self signed certificates */ "allow_self_signed" => true, /* Verify the peer certificate against our provided Certificate Authority root certificate */ "verify_peer" => false, /* Default to false pre PHP 5.6 */ /* Verify the peer name (e.g. hostname validation) */ /* Will use the hostname used to connec to the node */ "verify_peer_name" => false, /* Verify the server certificate has not expired */ "verify_expiry" => true, /* Only available in the MongoDB PHP Driver */ ), )); return array("context" => $ctx); } } -
Modify the context parameters as necessary to suit your environment and save the file. There is no need to change any other MongoDB connection URLs.
-
Restart MongoDB and apache servers. Now FileCloud should be able to connect to SSL enabled MongoDB server.