Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STREAM_CLIENT_PERSISTENT does not work in conjunction with useSsl => true #267

Open
particleflux opened this issue Jul 5, 2024 · 0 comments

Comments

@particleflux
Copy link
Contributor

particleflux commented Jul 5, 2024

Custom socketClientFlags with the STREAM_CLIENT_PERSISTENT flag set will not work with useSsl => true, due to attempting to re-enable encryption when it is already active.

Could probably check for the persistent flag in the bitmask and skip the SSL init conditionally.
Not that simple, as it could be an already open connection or a fresh one.

What steps will reproduce the problem?

Have a redis connection configured with:

'hostname' => '<your-redis-host>',
'port'     => '6379/sessions',
'database' => 2,
'useSSL'   => true,
'socketClientFlags' => STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT,

and do multiple requests.

What's expected?

Connection is reused successfully.

What do you get instead?

PHP Warning – [yii\base\ErrorException] stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in
/var/www/app/vendor/yiisoft/yii2-redis/src/Connection.php:646

Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleError()
#1 /var/www/app/vendor/yiisoft/yii2-redis/src/Connection.php(646): stream_socket_enable_crypto()
#2 /var/www/app/vendor/yiisoft/yii2-redis/src/Connection.php(759): yii\redis\Connection->open()
#3 /var/www/app/vendor/yiisoft/yii2-redis/src/Session.php(128): yii\redis\Connection->executeCommand()
#4 [internal function]: yii\redis\Session->readSession()
#5 /var/www/app/vendor/yiisoft/yii2/web/Session.php(149): session_start()
#6 /var/www/app/vendor/yiisoft/yii2/web/Session.php(699): yii\web\Session->open()
#7 /var/www/app/vendor/yiisoft/yii2/web/User.php(691): yii\web\Session->get()
#8 /var/www/app/vendor/yiisoft/yii2/web/User.php(199): yii\web\User->renewAuthStatus()
#9 /var/www/app/vendor/yiisoft/yii2/web/User.php(367): yii\web\User->getIdentity()
#10 /var/www/app/vendor/yiisoft/yii2/base/Component.php(139): yii\web\User->getIsGuest()
#11 /var/www/app/vendor/yiisoft/yii2-debug/src/panels/UserPanel.php(83): yii\base\Component->__get()
#12 /var/www/app/vendor/yiisoft/yii2/base/BaseObject.php(109): yii\debug\panels\UserPanel->init()
#13 [internal function]: yii\base\BaseObject->__construct()
#14 /var/www/app/vendor/yiisoft/yii2/di/Container.php(419): ReflectionClass->newInstanceArgs()
#15 /var/www/app/vendor/yiisoft/yii2/di/Container.php(170): yii\di\Container->build()
#16 /var/www/app/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get()
#17 /var/www/app/vendor/yiisoft/yii2-debug/src/Module.php(253): yii\BaseYii::createObject()
#18 /var/www/app/vendor/yiisoft/yii2-debug/src/Module.php(225): yii\debug\Module->initPanels()
#19 /var/www/app/vendor/yiisoft/yii2/base/BaseObject.php(109): yii\debug\Module->init()
#20 /var/www/app/vendor/yiisoft/yii2/base/Module.php(161): yii\base\BaseObject->__construct()
#21 [internal function]: yii\base\Module->__construct()
#22 /var/www/app/vendor/yiisoft/yii2/di/Container.php(419): ReflectionClass->newInstanceArgs()
#23 /var/www/app/vendor/yiisoft/yii2/di/Container.php(170): yii\di\Container->build()
#24 /var/www/app/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get()
#25 /var/www/app/vendor/yiisoft/yii2/base/Module.php(445): yii\BaseYii::createObject()
#26 /var/www/app/vendor/yiisoft/yii2/base/Application.php(313): yii\base\Module->getModule()
#27 /var/www/app/vendor/yiisoft/yii2/web/Application.php(69): yii\base\Application->bootstrap()
#28 /var/www/app/vendor/yiisoft/yii2/base/Application.php(271): yii\web\Application->bootstrap()
#29 /var/www/app/vendor/yiisoft/yii2/base/BaseObject.php(109): yii\base\Application->init()
#30 /var/www/app/vendor/yiisoft/yii2/base/Application.php(204): yii\base\BaseObject->__construct()
#31 /var/www/app/frontend/web/index.php(18): yii\base\Application->__construct()

Additional info

Q A
Yii version 2.0.49.4
PHP version 8.2.21
Operating system Linux / Debian
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant