3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
6
7
7
8
namespace Magento \Setup \Model ;
8
9
12
13
use Magento \Framework \Setup \ConfigOptionsListInterface ;
13
14
use Magento \Framework \Setup \Option \FlagConfigOption ;
14
15
use Magento \Framework \Setup \Option \TextConfigOption ;
16
+ use Magento \Setup \Model \ConfigOptionsList \DriverOptions ;
15
17
use Magento \Setup \Validator \DbValidator ;
16
18
17
19
/**
@@ -53,17 +55,24 @@ class ConfigOptionsList implements ConfigOptionsListInterface
53
55
\Magento \Setup \Model \ConfigOptionsList \Lock::class,
54
56
];
55
57
58
+ /**
59
+ * @var DriverOptions
60
+ */
61
+ private $ driverOptions ;
62
+
56
63
/**
57
64
* Constructor
58
65
*
59
66
* @param ConfigGenerator $configGenerator
60
67
* @param DbValidator $dbValidator
61
68
* @param KeyValidator|null $encryptionKeyValidator
69
+ * @param DriverOptions|null $driverOptions
62
70
*/
63
71
public function __construct (
64
72
ConfigGenerator $ configGenerator ,
65
73
DbValidator $ dbValidator ,
66
- KeyValidator $ encryptionKeyValidator = null
74
+ KeyValidator $ encryptionKeyValidator = null ,
75
+ DriverOptions $ driverOptions = null
67
76
) {
68
77
$ this ->configGenerator = $ configGenerator ;
69
78
$ this ->dbValidator = $ dbValidator ;
@@ -72,6 +81,7 @@ public function __construct(
72
81
$ this ->configOptionsCollection [] = $ objectManager ->get ($ className );
73
82
}
74
83
$ this ->encryptionKeyValidator = $ encryptionKeyValidator ?: $ objectManager ->get (KeyValidator::class);
84
+ $ this ->driverOptions = $ driverOptions ?? $ objectManager ->get (DriverOptions::class);
75
85
}
76
86
77
87
/**
@@ -162,6 +172,36 @@ public function getOptions()
162
172
ConfigOptionsListConstants::CONFIG_PATH_CACHE_HOSTS ,
163
173
'http Cache hosts '
164
174
),
175
+ new TextConfigOption (
176
+ ConfigOptionsListConstants::INPUT_KEY_DB_SSL_KEY ,
177
+ TextConfigOption::FRONTEND_WIZARD_TEXT ,
178
+ ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT_DRIVER_OPTIONS .
179
+ '/ ' . ConfigOptionsListConstants::KEY_MYSQL_SSL_KEY ,
180
+ 'Full path of client key file in order to establish db connection through SSL ' ,
181
+ ''
182
+ ),
183
+ new TextConfigOption (
184
+ ConfigOptionsListConstants::INPUT_KEY_DB_SSL_CERT ,
185
+ TextConfigOption::FRONTEND_WIZARD_TEXT ,
186
+ ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT_DRIVER_OPTIONS .
187
+ '/ ' . ConfigOptionsListConstants::KEY_MYSQL_SSL_CERT ,
188
+ 'Full path of client certificate file in order to establish db connection through SSL ' ,
189
+ ''
190
+ ),
191
+ new TextConfigOption (
192
+ ConfigOptionsListConstants::INPUT_KEY_DB_SSL_CA ,
193
+ TextConfigOption::FRONTEND_WIZARD_TEXT ,
194
+ ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT_DRIVER_OPTIONS .
195
+ '/ ' . ConfigOptionsListConstants::KEY_MYSQL_SSL_CA ,
196
+ 'Full path of server certificate file in order to establish db connection through SSL ' ,
197
+ ''
198
+ ),
199
+ new FlagConfigOption (
200
+ ConfigOptionsListConstants::INPUT_KEY_DB_SSL_VERIFY ,
201
+ ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT_DRIVER_OPTIONS .
202
+ '/ ' . ConfigOptionsListConstants::KEY_MYSQL_SSL_VERIFY ,
203
+ 'Verify server certification '
204
+ ),
165
205
];
166
206
167
207
foreach ($ this ->configOptionsCollection as $ configOptionsList ) {
@@ -349,12 +389,14 @@ private function validateDbSettings(array $options, DeploymentConfig $deployment
349
389
) {
350
390
try {
351
391
$ options = $ this ->getDbSettings ($ options , $ deploymentConfig );
392
+ $ driverOptions = $ this ->driverOptions ->getDriverOptions ($ options );
352
393
353
- $ this ->dbValidator ->checkDatabaseConnection (
394
+ $ this ->dbValidator ->checkDatabaseConnectionWithDriverOptions (
354
395
$ options [ConfigOptionsListConstants::INPUT_KEY_DB_NAME ],
355
396
$ options [ConfigOptionsListConstants::INPUT_KEY_DB_HOST ],
356
397
$ options [ConfigOptionsListConstants::INPUT_KEY_DB_USER ],
357
- $ options [ConfigOptionsListConstants::INPUT_KEY_DB_PASSWORD ]
398
+ $ options [ConfigOptionsListConstants::INPUT_KEY_DB_PASSWORD ],
399
+ $ driverOptions
358
400
);
359
401
} catch (\Exception $ exception ) {
360
402
$ errors [] = $ exception ->getMessage ();
0 commit comments