提问人:Raja 提问时间:2/26/2021 最后编辑:DharmanRaja 更新时间:3/5/2021 访问量:1563
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论坛联系时,我被要求检查以下链接。
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 开始抛出上述错误,我对此一无所知。
其他细节: Codeigniter 版本:3.1.11 PHP 7.3.11
下面是我在代码点火器端的连接字符串。
$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密钥。 在“加密密钥”中,创建一个数组,并用此键/值填充它。
‘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_key、ssl_cert 和 ssl_ca。就我而言,它通过 .ssl_verify => TRUE
ssl_verify ==> FALSE
因此SSL_VERIFY false 意味着不需要客户端验证,因此不需要证书、CA 和密钥路径。因此,这又是数据库的配置方式。如果它配置为需要客户端验证,则应将 SSL_VERIFY = TRUE 与其他所有其他详细信息一起传递。但就我而言,SSL_VERIFY = FALSE 很好。那可能是JAVA应用程序也没有遇到这个问题。
感谢大家的支持。
评论