I’m deploying a flask app on Heroku using a Redis premium plan. I get the following error: ‘SSL Certification Verify Failed’. Attempted fixes:
- Downgrading to Redis 5
- Passing
ssl_cert_reqs=None
to theRedis
constructor inredis-py
A solution to this problem could be:
- Explain how to disable TLS certification on heroku redis premium plans
- Explain how to make TLS certification work on heroku redis premium plans
From Heroku’s docs, this may be a hint: ‘you must enable TLS in your Redis client’s configuration in order to connect to a Redis 6 database’. I don’t understand what this means.
8
Answers
You can disable TLS certification on Heroku by downgrading to Redis 5 and passing
ssl_cert_reqs=None
to theRedis
constructor.My mistake was not doing both at the same time.
An ideal solution would explain how to configure TLS certification for Redis 6.
The docs are actually incorrect, you have to set SSL to verify_none because TLS happens automatically.
From Heroku support:
I solved this by setting the ssl_params to verify_none:
For me it was where I config redis (in a sidekiq initializer):
This solution works with redis 6 and python on Heroku
In my local development environment I do not use redis with the rediss scheme, so I use a function like this to allow work in both cases:
If using the
django-rq
wrapper and trying to deal with this, be sure to not use theURL
parameter withSSL_CERTS_REQS
. There is an outstanding issue that describes this all, but basically you need to specify each connection param instead of using the URL.I solved my problem by adding
?ssl_cert_reqs=CERT_NONE
to the end ofREDIS_URL
in my Heroku config.On Heroku (assuming Heroku Redis addon), the redis TLS route already has the
ssl_cert_reqs
param sorted out. A common oversight that can cause errors in cases like this on heroku is: usingREDIS_URL
overREDIS_TLS_URL
.Solution:
redis_url = os.environ.get('REDIS_TLS_URL')
Solution works for nodejs16 and redis client 4.6.x
I ran into difficulty on this but finally got it resolved…
A lot of documentation and posts on this topic are unclear. I’ve requested Heroku update their documentation on https://devcenter.heroku.com/articles/connecting-heroku-redis#connecting-in-python to include a specific change to the
Procfile
.It’s sort of mentioned above but refers to "Heroku config" instead of the
Procfile
specifically.In your
Procfile
add?ssl_cert_reqs=none
to$REDIS_URL
.e.g.:
Don’t update
REDIS_URL
directly as Heroku cycle this from time to time.I also updated the Redis setup as per the original documentation:
But it was the change to the
Procfile
that finally got Redis v6.2.11 with TLS working correctly for me.