From 3b829d019bea84f3215087e7fe3c8247eb438f30 Mon Sep 17 00:00:00 2001 From: Aliaksei Sanikovich Date: Thu, 26 Sep 2024 21:36:12 +0200 Subject: [PATCH] Add sslCA connection option --- src/ClickHouseConnection.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/ClickHouseConnection.php b/src/ClickHouseConnection.php index d138600..5c83bd9 100644 --- a/src/ClickHouseConnection.php +++ b/src/ClickHouseConnection.php @@ -38,15 +38,21 @@ public function __construct( string $password, AbstractPlatform $platform ) { - $this->client = new Client( - [ - 'host' => $params['host'] ?? 'localhost', - 'port' => $params['port'] ?? 8123, - 'username' => $user, - 'password' => $password, - ], - array_merge(['database' => $params['dbname'] ?? 'default'], $params['driverOptions'] ?? []) - ); + $connectParams = [ + 'host' => $params['host'] ?? 'localhost', + 'port' => $params['port'] ?? 8123, + 'username' => $user, + 'password' => $password, + ]; + + if (isset($params['driverOptions']['sslCA'])) { + $connectParams['sslCA'] = $params['driverOptions']['sslCA']; + unset($params['driverOptions']['sslCA']); + } + + $clientParams = array_merge(['database' => $params['dbname'] ?? 'default'], $params['driverOptions'] ?? []); + + $this->client = new Client($connectParams, $clientParams); $this->platform = $platform; }