Home » Database » DB » Bug #5657
SSL-Connection fails / vartype boolean
Details
| Request #5657 | SSL-Connection fails / vartype boolean |
|---|---|
| Submitted | 2005-10-11 14:52 UTC |
| From | karl dot schreiber at gmx dot net |
| Assigned | aharvey |
| Status | Closed |
| Package | DB |
| PHP Version | 5.0.5 |
| OS | SUSE LINUX 9.3 |
| Roadmaps | (Not assigned) |
Comments
[2005-10-11 14:52 UTC] karl dot schreiber at gmx dot net
Description:
------------
When i try to connect with ssl=1, connection fails because the type of the configuration variable 'ssl' is not boolean.
Example:
$db=&DB::connect($dsn,array('ssl'=>1)); // fails
$db=&DB::connect($dsn,array('ssl'=>true)); // ok
When i read an ini file for DB_DataObject then the variable type for ssl is string and ssl connection fails.
INI-File:
[DB_DataObject]
database = "mysqli://user:pass@host/db?ssl=1&key=client-key.pem&cert=client-cert.pem&ca=cacert.pem"
schema_location = db/schema/
class_location = db/
require_prefix = db/
class_prefix = DO_
extends_location = DB/DataObject.php
extends = DB_DataObject
[DB]
ssl = 1
Here i have a little workaround for this problem in function &connect() in DB.php:
foreach ($options as $option => $value) {
if(strtoupper($option)=='SSL') { $value=(bool)$value; }
$test = $obj->setOption($option, $value);
if (DB::isError($test)) {
return $test;
}
}
Test script:
---------------
require_once('DB.php');
$dsn=array(
'phptype' => 'mysqli',
'username' => 'user',
'password' => 'pass',
'hostspec' => 'host',
'database' => 'db',
'protocol' => 'tcp',
'ssl' => 1,
'cert' => 'client-cert.pem',
'key' => 'client-key.pem',
'ca' => 'cacert.pem'
);
$db=&DB::connect($dsn,array('ssl'=>1));
if(DB::isError($db)) {
die($db->getUserInfo());
}
echo "connected!\n";
$db->disconnect();
Expected result:
----------------
connected!
Actual result:
--------------
connection error because the type of the variable "ssl" is not boolean
[2005-10-13 09:29 UTC] karl dot schreiber at gmx dot net
You could patch DB/mysqli.php with this code in function connect():
...
if ($this->getOption('ssl') === true) {
...
[2005-10-13 09:30 UTC] karl dot schreiber at gmx dot net
You could patch DB/mysqli.php with this code in function connect():
...
if ((int)$this->getOption('ssl') === 1) {
...