-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Version: redis version 7.
Platform: python3.11 / redis in-memory instance in GCP
Description: I am trying to make a connection from a python script to an in-memory redis store.
It has an endpoint and is also AUTH and TLS enabled.
`
import redis
import certifi
REDIS_HOST = <primary endpoint>
REDIS_PORT = 6378
REDIS_PASSWORD = <password> # Auth value
REDIS_URL = f'rediss://{REDIS_PASSWORD}@{REDIS_HOST}:{REDIS_PORT}'
'''
redis_client = redis.Redis.from_url(
url=REDIS_URL,
ssl_cert_reqs='required', ssl_certfile = 'server-ca.pem'
)
print(redis_client.ping())
def test_connection():
try:
redis_client.set('test_key', 'test_value')
value = redis_client.get('test_key')
print(f"Successfully connected to Redis.{value}")
except redis.RedisError as e:
print(f"Error connecting to Redis: {e}")
test_connection()
'''
REDIS_URL = f'rediss://{REDIS_PASSWORD}@{REDIS_HOST}:{REDIS_PORT}?decode_responses=True&protocol=3'
url_connection = redis.from_url(REDIS_URL)
url_connection.ping()
`
This is the error I get when I run my script to test the connection. From the code, it can be observed that I tried with SSL option as well, but it fails there too. [commented that portion]. The last few lines that I have is throwing the error that I have shared in the issue right now.
I am not sure how to resolve this issue. really appreciate if some pointers can be shared.
Traceback (most recent call last):
File "/home/EN_ie/.local/lib/python3.11/site-packages/redis/connection.py", line 357, in connect
sock = self.retry.call_with_retry(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/EN_ie/.local/lib/python3.11/site-packages/redis/retry.py", line 62, in call_with_retry
return do()
^^^^
File "/home/EN_ie/.local/lib/python3.11/site-packages/redis/connection.py", line 358, in
lambda: self._connect(), lambda error: self.disconnect(error)
^^^^^^^^^^^^^^^
File "/home/EN_ie/.local/lib/python3.11/site-packages/redis/connection.py", line 1021, in _connect
return self._wrap_socket_with_ssl(sock)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/EN_ie/.local/lib/python3.11/site-packages/redis/connection.py", line 1066, in _wrap_socket_with_ssl
sslsock = context.wrap_socket(sock, server_hostname=self.host)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.11/ssl.py", line 517, in wrap_socket
return self.sslsocket_class._create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.11/ssl.py", line 1104, in _create
self.do_handshake()
File "/usr/lib64/python3.11/ssl.py", line 1382, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1006)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/EN_ie/redisc_withurl.py", line 43, in
url_connection.ping()
File "/home/EN_ie/.local/lib/python3.11/site-packages/redis/commands/core.py", line 1212, in ping
return self.execute_command("PING", **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/EN_ie/.local/lib/python3.11/site-packages/redis/client.py", line 559, in execute_command
return self._execute_command(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/EN_ie/.local/lib/python3.11/site-packages/redis/client.py", line 565, in _execute_command
conn = self.connection or pool.get_connection(command_name, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/EN_ie/.local/lib/python3.11/site-packages/redis/connection.py", line 1422, in get_connection
connection.connect()
File "/home/EN_ie/.local/lib/python3.11/site-packages/redis/connection.py", line 363, in connect
raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 1 connecting to 10.0.0.5:6378. [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1006).