From 9b107027ed73da1f2ffeafb2faf30c441fe2fb70 Mon Sep 17 00:00:00 2001 From: joyqi Date: Fri, 22 Sep 2023 13:51:35 +0800 Subject: [PATCH] add pgsql ssl mode support (ref #1600) (#1623) --- install.php | 8 ++++--- install/Mysql.php | 2 +- install/Pgsql.php | 33 +++++++++++++++++++++------- var/Typecho/Db/Adapter/Pdo/Pgsql.php | 8 ++++++- var/Typecho/Db/Adapter/Pgsql.php | 4 ++++ 5 files changed, 42 insertions(+), 13 deletions(-) diff --git a/install.php b/install.php index 3c98e925..fdc7a05c 100644 --- a/install.php +++ b/install.php @@ -926,7 +926,7 @@ function install_step_2_perform() 'dbDatabase' => null, 'dbEngine' => 'InnoDB', 'dbSslCa' => null, - 'dbSslVerify' => 'on', + 'dbSslVerify' => 'off', ], 'Pgsql' => [ 'dbHost' => 'localhost', @@ -935,6 +935,7 @@ function install_step_2_perform() 'dbPassword' => null, 'dbCharset' => 'utf8', 'dbDatabase' => null, + 'dbSslVerify' => 'off', ], 'SQLite' => [ 'dbFile' => __TYPECHO_ROOT_DIR__ . '/usr/' . uniqid() . '.db' @@ -956,7 +957,7 @@ function install_step_2_perform() 'dbAdapter' => $request->getServer('TYPECHO_DB_ADAPTER', install_get_current_db_driver()), 'dbNext' => $request->getServer('TYPECHO_DB_NEXT', 'none'), 'dbSslCa' => $request->getServer('TYPECHO_DB_SSL_CA'), - 'dbSslVerify' => $request->getServer('TYPECHO_DB_SSL_VERIFY', 'on'), + 'dbSslVerify' => $request->getServer('TYPECHO_DB_SSL_VERIFY', 'off'), ]; } else { $config = $request->from([ @@ -1024,6 +1025,7 @@ function install_step_2_perform() ->addRule('dbCharset', 'required', _t('确认您的配置')) ->addRule('dbCharset', 'enum', _t('确认您的配置'), ['utf8']) ->addRule('dbDatabase', 'required', _t('确认您的配置')) + ->addRule('dbSslVerify', 'enum', _t('确认您的配置'), ['on', 'off']) ->run($config); break; case 'SQLite': @@ -1058,7 +1060,7 @@ function install_step_2_perform() // bool ssl verify if (isset($dbConfig['sslVerify'])) { - $dbConfig['sslVerify'] = $dbConfig['sslVerify'] == 'on'; + $dbConfig['sslVerify'] = $dbConfig['sslVerify'] == 'on' || !empty($dbConfig['sslCa']); } if (isset($dbConfig['file']) && preg_match("/^[a-z0-9]+\.[a-z0-9]{2,}$/i", $dbConfig['file'])) { diff --git a/install/Mysql.php b/install/Mysql.php index eb3e20ab..f5f66d07 100644 --- a/install/Mysql.php +++ b/install/Mysql.php @@ -76,8 +76,8 @@
  • diff --git a/install/Pgsql.php b/install/Pgsql.php index ac89e04c..75d48aa6 100644 --- a/install/Pgsql.php +++ b/install/Pgsql.php @@ -6,13 +6,6 @@

    -