Skip to content

sqlsrv driver needs encrypt state in config array #265

@DaniDuesentrieb

Description

@DaniDuesentrieb

Steps to reproduce the issue

If you want to Connect to an unencrpyted MsSQL Server with the following connection array, a connection could not be established, because the encryption could not be set.

$option['driver'] = 'sqlsrv'; 
$option['host'] = 'server\\instancename, 1433';
$option['port'] = 1433;
$option['user'] = 'user';
$option['password'] = 'pass';
$option['database'] = 'DBName';
$option['prefix'] = '';

return JDatabaseDriver::getInstance($option);

Expected result

In the config array there is an option "encrypt" to set the state.

$option['driver'] = 'sqlsrv'; 
$option['host'] = 'server\\instancename, 1433';
$option['port'] = 1433;
$option['user'] = 'user';
$option['password'] = 'pass';
$option['database'] = 'DBName';
$option['prefix'] = '';
$option['encrypt'] = false;

return JDatabaseDriver::getInstance($option);

Actual result

System information (as much as possible)

Joomla 4.1.4
PHP 7.4.28
Linux Ubuntu Webserver
sql_srv extension 5.10.0

Additional comments

In the file libraries\vendor\joomla\database\src\Sqlsrv\SqlsrvDriver.php at line 117 to 124 the config array needs the option encrypt, so the array must be change from this:

$config = [
	'Database'             => $this->options['database'],
	'uid'                  => $this->options['user'],
	'pwd'                  => $this->options['password'],
	'CharacterSet'         => 'UTF-8',
	'ReturnDatesAsStrings' => true
];

to this:

$config = [
	'Database'             => $this->options['database'],
	'uid'                  => $this->options['user'],
	'pwd'                  => $this->options['password'],
	'CharacterSet'         => 'UTF-8',
	'ReturnDatesAsStrings' => true,
	'encrypt'	       => $this->options['encrypt']
];

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions