Codeigniter 3 MySQLi 安全数据库连接
Codeigniter 3 MySQLi Secure db connection
最近我的数据库团队为加密连接升级了数据库。我们使用 Codeigniter 3 构建的门户开始出现以下错误。
Severity: Warning
Message: mysqli::real_connect(): (HY000/3159): Connections using insecure transport are prohibited while --require_secure_transport=ON.
Filename: mysqli/mysqli_driver.php
Line Number: 203
之前在数据库端进行此更改之前,它运行良好。当我尝试查看 Codeigniter 论坛时,我被要求检查以下 link.
https://forum.codeigniter.com/thread-77193-post-384725.html#pid384725 --> https://dev.mysql.com/doc/mysql-security-excerpt/8.0/en/using-encrypted-connections.html#using-encrypted-connections-client-side-configuration
我们有两个站点,一个是使用 Sprint 启动 (Java) 构建的,它只使用 (useSSL=true),他们没有遇到这些问题。但是 Codeigniter 开始抛出上述错误,我对此一无所知。
其他详情:
代码点火器版本:3.1.11
PHP7.3.11
下面还有我在 codeigniter 端的连接字符串。
$db['default'] = array(
'dsn' => '',
'hostname' => 'dbhost',
'username' => 'dbusername',
'password' => 'password',
'database' => 'dbname',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE,
);
您需要更多配置才能在 MySQL 连接上设置 SSL 密钥。
在加密密钥中创建一个数组并用 key/values.
填充它
‘ssl_key’ - Path to the private key file
‘ssl_cert’ - Path to the public key certificate file
‘ssl_ca’ - Path to the certificate authority file
‘ssl_capath’ - Path to a directory containing trusted CA certificates in PEM format
‘ssl_cipher’ - List of allowed ciphers to be used for the encryption, separated by colons (‘:’)
‘ssl_verify’ - TRUE/FALSE; Whether to verify the server certificate or not (‘mysqli’ only)
我想,我想通了。它只是期待我 SSL_VERIFY => FALSE,然后它与 MySQL.
连接
'encrypt' => [
'ssl_verify' => FALSE
],
如果我提供 ssl_verify => TRUE
,则需要所有其他参数 ssl_key、ssl_cert 和 ssl_ca。在我的例子中,它通过 ssl_verify ==> FALSE
.
自动连接到 MySQL
so SSL_VERIFY false 表示不需要客户端验证,因此不需要证书、ca 和密钥路径。所以这又是您的数据库的配置方式。如果配置为期望需要客户端验证,那么您应该传递 SSL_VERIFY = TRUE 以及其他所有其他详细信息。但就我而言,SSL_VERIFY = FALSE 没问题。那可能是 JAVA 应用程序也没有遇到这个问题。
感谢大家的支持
最近我的数据库团队为加密连接升级了数据库。我们使用 Codeigniter 3 构建的门户开始出现以下错误。
Severity: Warning
Message: mysqli::real_connect(): (HY000/3159): Connections using insecure transport are prohibited while --require_secure_transport=ON.
Filename: mysqli/mysqli_driver.php
Line Number: 203
之前在数据库端进行此更改之前,它运行良好。当我尝试查看 Codeigniter 论坛时,我被要求检查以下 link.
https://forum.codeigniter.com/thread-77193-post-384725.html#pid384725 --> https://dev.mysql.com/doc/mysql-security-excerpt/8.0/en/using-encrypted-connections.html#using-encrypted-connections-client-side-configuration
我们有两个站点,一个是使用 Sprint 启动 (Java) 构建的,它只使用 (useSSL=true),他们没有遇到这些问题。但是 Codeigniter 开始抛出上述错误,我对此一无所知。
其他详情: 代码点火器版本:3.1.11 PHP7.3.11
下面还有我在 codeigniter 端的连接字符串。
$db['default'] = array(
'dsn' => '',
'hostname' => 'dbhost',
'username' => 'dbusername',
'password' => 'password',
'database' => 'dbname',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE,
);
您需要更多配置才能在 MySQL 连接上设置 SSL 密钥。 在加密密钥中创建一个数组并用 key/values.
填充它‘ssl_key’ - Path to the private key file
‘ssl_cert’ - Path to the public key certificate file
‘ssl_ca’ - Path to the certificate authority file
‘ssl_capath’ - Path to a directory containing trusted CA certificates in PEM format
‘ssl_cipher’ - List of allowed ciphers to be used for the encryption, separated by colons (‘:’)
‘ssl_verify’ - TRUE/FALSE; Whether to verify the server certificate or not (‘mysqli’ only)
我想,我想通了。它只是期待我 SSL_VERIFY => FALSE,然后它与 MySQL.
连接'encrypt' => [
'ssl_verify' => FALSE
],
如果我提供 ssl_verify => TRUE
,则需要所有其他参数 ssl_key、ssl_cert 和 ssl_ca。在我的例子中,它通过 ssl_verify ==> FALSE
.
so SSL_VERIFY false 表示不需要客户端验证,因此不需要证书、ca 和密钥路径。所以这又是您的数据库的配置方式。如果配置为期望需要客户端验证,那么您应该传递 SSL_VERIFY = TRUE 以及其他所有其他详细信息。但就我而言,SSL_VERIFY = FALSE 没问题。那可能是 JAVA 应用程序也没有遇到这个问题。
感谢大家的支持