Menu

#352 Feature request - MySQL SSL connection + Workaround

1.1
closed
nobody
MySQL (1) SSL (1)
1
2016-02-02
2015-09-18
Anonymous
No

I have issue when using phpIPAM with our database which require SSL connection as it sits on another machine.
It would be nice to have this feature add in the next release.

I have created a crude work around which hopefully help kick start the process.


Modify functions/checkPhpBuild.php

if($_GET['page']!="install") {
// Non-SSL connection
// $mysqli = @new mysqli($db['host'], $db['user'], $db['pass'], $db['name']);
// End of Non-SSL connection

    // SSL Connection
    $mysqli = mysqli_init();
    $mysqli->real_connect($db['host'], $db['user'], $db['pass'], $db['name'], 3306, NULL, MYSQLI_CLIENT_SSL);
    // End of SSL Connection

    // check connection
    if ($mysqli->connect_errno) {
            // die with error
        die('<div class="alert alert-danger"><strong>'._('Database connection failed').'!</strong><br><hr>Error: '. mysqli_connect_error() .'</div>');
    }

}

Modify functions/dbfunctions.php

    public function __construct($host = NULL, $username = NULL, $dbname = NULL, $port = NULL, $socket = NULL, $printError = true) {

            # throw exceptions
            mysqli_report(MYSQLI_REPORT_STRICT);

            # open database connection
            // SSL Connection
            parent::__construct();
            try { $this->real_connect($host, $username, $dbname, $port, $socket, NULL, MYSQLI_CLIENT_SSL); }
            // End of SSL Connection

            // Non-SSL connection

// try { parent::__construct($host, $username, $dbname, $port, $socket); }
// End of Non-SSL connection
catch (Exception $e) {
if($printError) { print "

error:".$e->getMessage()."
"; }
return false;
}

            if(!isset($e))
            $this->set_charset("utf8");

            # change back reporting for exception throwing to scripts
            //mysqli_report(MYSQLI_REPORT_ERROR);
    }

Discussion

  • Miha Petkovsek

    Miha Petkovsek - 2015-10-12

    Hi ! Can you check 1.2 beta (https://github.com/phpipam/phpipam) and test / find solution ? I moved to pdo from mysqli.

     
  • Miha Petkovsek

    Miha Petkovsek - 2016-02-02
    • status: open --> closed
     
  • Miha Petkovsek

    Miha Petkovsek - 2016-02-02

    Implemented in 1.2

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.