Add option to disable Mysql SSL server verification

This commit is contained in:
Frédéric Guillot 2018-01-11 14:01:32 -08:00
parent f7c6cbd0f4
commit d35d5beee2
10 changed files with 141 additions and 111 deletions

View File

@ -135,6 +135,7 @@ class DatabaseProvider implements ServiceProviderInterface
'ssl_key' => DB_SSL_KEY,
'ssl_ca' => DB_SSL_CA,
'ssl_cert' => DB_SSL_CERT,
'verify_server_cert' => DB_VERIFY_SERVER_CERT,
));
}

View File

@ -53,6 +53,7 @@ defined('DB_PORT') or define('DB_PORT', null);
defined('DB_SSL_KEY') or define('DB_SSL_KEY', null);
defined('DB_SSL_CERT') or define('DB_SSL_CERT', null);
defined('DB_SSL_CA') or define('DB_SSL_CA', null);
defined('DB_VERIFY_SERVER_CERT') or define('DB_VERIFY_SERVER_CERT', null);
// Database backend group provider
defined('DB_GROUP_PROVIDER') or define('DB_GROUP_PROVIDER', true);

View File

@ -30,7 +30,7 @@
"eluceo/ical": "0.10.1",
"erusev/parsedown" : "1.6.0",
"fguillot/json-rpc" : "1.2.1",
"fguillot/picodb" : "1.0.14",
"fguillot/picodb" : "1.0.15",
"miniflux/picofeed": "0.1.34",
"fguillot/simpleLogger" : "1.0.1",
"fguillot/simple-validator" : "1.0.1",

22
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "55f5db0718c2a102000edeebf460165e",
"content-hash": "fa5e1f971060c305f81531da883b01ad",
"packages": [
{
"name": "aferrandini/phpqrcode",
@ -288,16 +288,16 @@
},
{
"name": "fguillot/picodb",
"version": "v1.0.14",
"version": "v1.0.15",
"source": {
"type": "git",
"url": "https://github.com/fguillot/picoDb.git",
"reference": "86a831302ab10af800c83dbe4b3b01c88d5433f1"
"reference": "1dccdf9e1309545e68d7161668cfcb084f0f5e09"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fguillot/picoDb/zipball/86a831302ab10af800c83dbe4b3b01c88d5433f1",
"reference": "86a831302ab10af800c83dbe4b3b01c88d5433f1",
"url": "https://api.github.com/repos/fguillot/picoDb/zipball/1dccdf9e1309545e68d7161668cfcb084f0f5e09",
"reference": "1dccdf9e1309545e68d7161668cfcb084f0f5e09",
"shasum": ""
},
"require": {
@ -324,7 +324,7 @@
],
"description": "Minimalist database query builder",
"homepage": "https://github.com/fguillot/picoDb",
"time": "2016-07-16T22:59:59+00:00"
"time": "2018-01-11T21:47:49+00:00"
},
{
"name": "fguillot/simple-queue",
@ -992,16 +992,16 @@
},
{
"name": "symfony/finder",
"version": "v3.4.2",
"version": "v3.4.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "dac8d7db537bac7ad8143eb11360a8c2231f251a"
"reference": "613e26310776f49a1773b6737c6bd554b8bc8c6f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/dac8d7db537bac7ad8143eb11360a8c2231f251a",
"reference": "dac8d7db537bac7ad8143eb11360a8c2231f251a",
"url": "https://api.github.com/repos/symfony/finder/zipball/613e26310776f49a1773b6737c6bd554b8bc8c6f",
"reference": "613e26310776f49a1773b6737c6bd554b8bc8c6f",
"shasum": ""
},
"require": {
@ -1037,7 +1037,7 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"time": "2017-11-05T16:10:10+00:00"
"time": "2018-01-03T07:37:34+00:00"
},
{
"name": "symfony/polyfill-mbstring",

View File

@ -85,6 +85,9 @@ define('DB_SSL_CERT', null);
// Mysql SSL CA
define('DB_SSL_CA', null);
// Mysql SSL server verification, set to false if you don't want the Mysql driver to validate the certificate CN
define('DB_VERIFY_SERVER_CERT', null);
// Enable LDAP authentication (false by default)
define('LDAP_AUTH', false);

View File

@ -291,48 +291,6 @@
"description": "Simple Json-RPC client/server library that just works",
"homepage": "https://github.com/fguillot/JsonRPC"
},
{
"name": "fguillot/picodb",
"version": "v1.0.14",
"version_normalized": "1.0.14.0",
"source": {
"type": "git",
"url": "https://github.com/fguillot/picoDb.git",
"reference": "86a831302ab10af800c83dbe4b3b01c88d5433f1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fguillot/picoDb/zipball/86a831302ab10af800c83dbe4b3b01c88d5433f1",
"reference": "86a831302ab10af800c83dbe4b3b01c88d5433f1",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "4.8.*"
},
"time": "2016-07-16T22:59:59+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-0": {
"PicoDb": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Frédéric Guillot",
"homepage": "https://github.com/fguillot/"
}
],
"description": "Minimalist database query builder",
"homepage": "https://github.com/fguillot/picoDb"
},
{
"name": "fguillot/simple-queue",
"version": "v1.0.1",
@ -1076,57 +1034,6 @@
"mailer"
]
},
{
"name": "symfony/finder",
"version": "v3.4.2",
"version_normalized": "3.4.2.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "dac8d7db537bac7ad8143eb11360a8c2231f251a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/dac8d7db537bac7ad8143eb11360a8c2231f251a",
"reference": "dac8d7db537bac7ad8143eb11360a8c2231f251a",
"shasum": ""
},
"require": {
"php": "^5.5.9|>=7.0.8"
},
"time": "2017-11-05T16:10:10+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.4-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Symfony\\Component\\Finder\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com"
},
{
"name": "gregwar/captcha",
"version": "v1.1.4",
@ -1181,5 +1088,98 @@
"captcha",
"spam"
]
},
{
"name": "fguillot/picodb",
"version": "v1.0.15",
"version_normalized": "1.0.15.0",
"source": {
"type": "git",
"url": "https://github.com/fguillot/picoDb.git",
"reference": "1dccdf9e1309545e68d7161668cfcb084f0f5e09"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fguillot/picoDb/zipball/1dccdf9e1309545e68d7161668cfcb084f0f5e09",
"reference": "1dccdf9e1309545e68d7161668cfcb084f0f5e09",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "4.8.*"
},
"time": "2018-01-11T21:47:49+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-0": {
"PicoDb": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Frédéric Guillot",
"homepage": "https://github.com/fguillot/"
}
],
"description": "Minimalist database query builder",
"homepage": "https://github.com/fguillot/picoDb"
},
{
"name": "symfony/finder",
"version": "v3.4.3",
"version_normalized": "3.4.3.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "613e26310776f49a1773b6737c6bd554b8bc8c6f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/613e26310776f49a1773b6737c6bd554b8bc8c6f",
"reference": "613e26310776f49a1773b6737c6bd554b8bc8c6f",
"shasum": ""
},
"require": {
"php": "^5.5.9|>=7.0.8"
},
"time": "2018-01-03T07:37:34+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.4-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Symfony\\Component\\Finder\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com"
}
]

View File

@ -98,6 +98,14 @@ class Mysql extends Base
$options[PDO::MYSQL_ATTR_SSL_CA] = $settings['ssl_ca'];
}
if (! empty($settings['persistent'])) {
$options[PDO::ATTR_PERSISTENT] = $settings['persistent'];
}
if (isset($settings['verify_server_cert'])) {
$options[PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT] = $settings['verify_server_cert'];
}
return $options;
}

View File

@ -20,9 +20,6 @@ class Postgres extends Base
* @var array
*/
protected $requiredAttributes = array(
'hostname',
'username',
'password',
'database',
);
@ -42,13 +39,25 @@ class Postgres extends Base
*/
public function createConnection(array $settings)
{
$dsn = 'pgsql:host='.$settings['hostname'].';dbname='.$settings['database'];
$dsn = 'pgsql:dbname='.$settings['database'];
if (! empty($settings['username'])) {
$dsn .= ';user='.$settings['username'];
}
if (! empty($settings['password'])) {
$dsn .= ';password='.$settings['password'];
}
if (! empty($settings['hostname'])) {
$dsn .= ';host='.$settings['hostname'];
}
if (! empty($settings['port'])) {
$dsn .= ';port='.$settings['port'];
}
$this->pdo = new PDO($dsn, $settings['username'], $settings['password']);
$this->pdo = new PDO($dsn);
if (isset($settings['schema_table'])) {
$this->schemaTable = $settings['schema_table'];

View File

@ -718,4 +718,12 @@ class Table
call_user_func_array(array($this->conditionBuilder, $name), $arguments);
return $this;
}
/**
* Clone function ensures that cloned objects are really clones
*/
public function __clone()
{
$this->conditionBuilder = clone $this->conditionBuilder;
}
}

View File

@ -1,4 +1,4 @@
Copyright (c) 2004-2017 Fabien Potencier
Copyright (c) 2004-2018 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal