Page tree
Skip to end of metadata
Go to start of metadata


By default, FileCloud will connect to a MongoDB server in plain text mode. Starting v14.x, FileCloud can be enabled to connect to MongoDB server in SSL mode.

Enabling SSL Mode Connection

  1. 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
     * Copyright(c) 2015 CodeLathe LLC. All rights Reserved.
     * This file is part of Tonido FileCloud
    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);
  2. 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. 
  3. Restart MongoDB and apache servers. Now FileCloud should be able to connect to SSL enabled MongoDB server.
  • No labels