-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
OpenSSL.SSL.Error #6
Comments
I see you created the related issue https://github.com/horazont/aioxmpp/issues/282 |
The same issue on osX python 3.7 |
For the record, I managed to get this working by: from aiofcm.connection import FCMXMPPConnection, FCMConnectionPool, logger
from aiofcm import FCM, Message, PRIORITY_HIGH
import aioxmpp
import certifi
def certifi_factory():
"""Creates a SSL context using the root CA certificates that ship with :mod:`certifi`.
"""
ctx = aioxmpp.security_layer.default_ssl_context()
ctx.load_verify_locations(certifi.where())
return ctx
class CertifiConnection(FCMXMPPConnection):
def _create_client(self, sender_id, api_key, loop=None) -> aioxmpp.Client:
"""Overrides the default :meth:`_create_client so that a custom certificate location
can be specified for the root CA certificates.
"""
xmpp_client = aioxmpp.Client(
local_jid=aioxmpp.JID.fromstr('%s@gcm.googleapis.com' % sender_id),
security_layer=aioxmpp.make_security_layer(api_key)._replace(
ssl_context_factory=certifi_factory,
),
override_peer=[
(self.FCM_HOST, self.FCM_PORT,
aioxmpp.connector.XMPPOverTLSConnector())
],
loop=loop
)
xmpp_client.on_stream_established.connect(
lambda: self._wait_connection.set_result(True)
)
xmpp_client.on_stream_destroyed.connect(
self._on_stream_destroyed
)
xmpp_client.on_failure.connect(
lambda exc: self._wait_connection.set_exception(exc)
)
xmpp_client.stream.register_message_callback(
type_=aioxmpp.MessageType.NORMAL,
from_=None,
cb=self.on_response
)
return xmpp_client
class CertifiConnectionPool(FCMConnectionPool):
async def connect(self) -> CertifiConnection:
connection = CertifiConnection(
sender_id=self.sender_id,
api_key=self.api_key,
loop=self.loop,
)
await connection.connect()
logger.info('Connection established (total: %d)',
len(self.connections) + 1)
return connection
class CertifiFCM(FCM):
def __init__(self, sender_id, api_key, max_connections=10, loop=None):
# type: (int, str, int, Optional[asyncio.AbstractEventLoop]) -> NoReturn
self.pool = CertifiConnectionPool(sender_id, api_key, max_connections, loop) This was combining some of the suggestions from related issues. I don't have time to put together a pull request, figure out the testing strategy, etc. But, perhaps @Fatal1ty could bring this in as a keyword argument to the |
Thank you @rosenbrockc. I will look into it when I have time. |
Hi! I try run example code, and get follow traceback (Python 3.5.6 on windows7 and debian8):
The text was updated successfully, but these errors were encountered: