Fatal1ty / aiofcm

An efficient Firebase Cloud Messaging Client Library for Python/asyncio
Apache License 2.0
34 stars 19 forks source link

OpenSSL.SSL.Error: [('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')] #5

Closed asleea88 closed 5 years ago

asleea88 commented 6 years ago

I run test code which is offered in README with my sender_id, api_key and device token.

However, the below exception happens.

[('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')]
Traceback (most recent call last):
  File "/Users/sangminkim/Library/Python/3.6/lib/python/site-packages/aioopenssl/__init__.py", line 331, in _tls_do_handshake
    self._tls_conn.do_handshake()
  File "/Users/sangminkim/Library/Python/3.6/lib/python/site-packages/OpenSSL/SSL.py", line 1907, in do_handshake
    self._raise_ssl_error(self._ssl, result)
  File "/Users/sangminkim/Library/Python/3.6/lib/python/site-packages/OpenSSL/SSL.py", line 1639, in _raise_ssl_error
    _raise_current_error()
  File "/Users/sangminkim/Library/Python/3.6/lib/python/site-packages/OpenSSL/_util.py", line 54, in exception_from_error_queue
    raise exception_type(errors)
OpenSSL.SSL.Error: [('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')]
invalid state
Traceback (most recent call last):
  File "/Users/sangminkim/Library/Python/3.6/lib/python/site-packages/aioopenssl/__init__.py", line 331, in _tls_do_handshake
    self._tls_conn.do_handshake()
  File "/Users/sangminkim/Library/Python/3.6/lib/python/site-packages/OpenSSL/SSL.py", line 1907, in do_handshake
    self._raise_ssl_error(self._ssl, result)
  File "/Users/sangminkim/Library/Python/3.6/lib/python/site-packages/OpenSSL/SSL.py", line 1639, in _raise_ssl_error
    _raise_current_error()
  File "/Users/sangminkim/Library/Python/3.6/lib/python/site-packages/OpenSSL/_util.py", line 54, in exception_from_error_queue
    raise exception_type(errors)
OpenSSL.SSL.Error: [('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/events.py", line 145, in _run
    self._callback(*self._args)
  File "/Users/sangminkim/Library/Python/3.6/lib/python/site-packages/aioopenssl/__init__.py", line 346, in _tls_do_handshake
    self._waiter.set_exception(exc)
asyncio.base_futures.InvalidStateError: invalid state
from uuid import uuid4
from aiofcm import FCM, Message, PRIORITY_HIGH

async def run():
    fcm = FCM('<NUMERICAL_SENDER_ID>', '<API_KEY>')
    message = Message(
        device_token='<DEVICE_TOKEN>',
        notification={           # optional
            "title": "Hello from Firebase",
            "body": "This is notification",
            "sound": "default"
        },
        data={"score": "3x1"},   # optional
        message_id=str(uuid4()),  # optional
        time_to_live=3,          # optional
        priority=PRIORITY_HIGH,  # optional
    )
    await fcm.send_message(message)

loop = asyncio.get_event_loop()
loop.run_until_complete(run())

python3.6.5 aioapns==1.4 aiofcm==1.1.0 aiohttp==3.3.2 aioopenssl==0.4.0 aiosasl==0.3.1 aioxmpp==0.9.0

Fatal1ty commented 6 years ago

@asleea88 It seems like in your environment an attempt to establish connection with host fcm-xmpp.googleapis.com is redirected to another host therefore certificate verification fails.

Fatal1ty commented 5 years ago

Try to update aiofcm version. If the problem persists, open a new issue.