Laravel with Heroku Redis and SSLFebruary 22, 2023
Redis 6.x appears to require SSL for connections and that's a problem with Heroku. Heroku does have documentation on how to get around errors with self-signed cerificates but it falls short of addressing the solution specifically for Laravel apps.
Redis::connect(): SSL operation failed with code 1. OpenSSL Error messages: error:0A000086:SSL routines::certificate verify failed
config/database.php under the
redis key you can control the options for your Redis connection. Here you can add a
context which sets
false so that the certificate issues are ignored. In the code below I've only applied these options in the production environment as it's not a concern for my local environment.
'options' => [ 'cluster' => env('REDIS_CLUSTER', 'redis'), 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), 'context' => env('APP_ENV') === 'production' ? [ 'stream' => [ 'verify_peer' => false, 'verify_peer_name' => false, ], ] : , ],
A blog about Laravel & Rails by Dwight Watson;
developer of Roomies.com, myRent.co.nz, High School Notes & StudentVIP.com.au.