codeigniter4 / CodeIgniter4

Open Source PHP Framework (originally from EllisLab)
https://codeigniter.com/
MIT License
5.4k stars 1.9k forks source link

Bug: Can't connect to Redis with Session RedisHandler over TLS #7178

Closed boring-joey closed 1 year ago

boring-joey commented 1 year ago

PHP Version

8.1

CodeIgniter4 Version

4.3.1

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Windows, Linux

Which server did you use?

apache

What happened?

I use a MS Azure Redis server which needs to be connected over TLS. When i set the $sessionDriver to the RedisHandler in the App.php file i edited the savePath to: tls://nameofserver.redis.cache.windows.net:6380?auth=password

When i debug the '/framework/system/Session/Handlers/RedisHandler.php' and check the '$this->savePath'. i see the following output because of the preg_match():

Array ( [host] => tls [port] => 6379 [password] => [database] => 0 [timeout] => 0 )

This results in the Redis server not connecting and it gives a RedisException error.

Steps to Reproduce

Add 'tls://' to the Redis database server url.

Expected Output

Array ( [host] => tls://nameofserver.redis.cache.windows.net [port] => 6380 [password] => password [database] => 0 [timeout] => 0 )

Anything else?

I managed to bypass this (hopefully temporary) by copying the system folder in our project folder and hardcoded the Redis Server URL.

ddevsr commented 1 year ago

For now we connect to Redis without Protocol

I send PR #7187, @TOAD-Joey can try this changes?

boring-joey commented 1 year ago

@ddevsr Yes, great, this fixes the issue.