question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to create secure server client application using python-socketio?

See original GitHub issue

I need to create secure connections over https/wss. I was going through this python-grpc-ssl library and I need something similar. WebSockets’ secure example offers similar functionality, but I can’t use it as I need event-based communication that this library offer.

For my simple tests, I have generated my own certificate and key. I am using aiohttp server where I am passing the above to ssl_context argument like so:

ssl_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
ssl_context.load_cert_chain('myRootCA.pem','myRootCA.key')
web.run_app(self.app, port=8080, ssl_context=ssl_context)

This creates an https server on port 8443 which I intend to connect to. I am unable to figure out how to go about this with the python socket-io client. For my use case, I need the server and client to verify each other and hence passing ssl_verify=False is not an option for me. Please help me understand how I can go about this.

Thanks.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
miguelgrinbergcommented, Aug 5, 2020

I personally prefer to handle the encryption outside of the Python server. Nginx works really well for this. So there are ways to support TLS and certificates, just not in the same server.

0reactions
miguelgrinbergcommented, Dec 28, 2020

@Ivaylo-Korakov Are you interested in server-side SSL support? This issue is for client-side, and as I said above, it can be implemented by passing an initialized requests or aiohttp session. For server-side SSL you can enable SSL in your web server, this package does not have its own web server.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Socket.IO Server — python-socketio documentation
Server () class creates a server compatible with the Python standard library. ... The Socket.IO server can be configured to serve static files...
Read more >
How to build a secure WebSocket server in Python - Snyk
This tutorial will explore building a secure WebSocket server in Python using python-socket.io and JavaScript Socket.IO client to connect ...
Read more >
Socket Programming in Python: Client, Server, Peer | PubNub
To use a socket object in the program, import the socket library that comes natively with Python. You'll then create a new socket...
Read more >
ssl - Secure communication between flask-socketio server and ...
I created a certificate using openssl ( rootCA.pem ) and added it to the Mac's keychain. After that, I issued server.cert and server.key...
Read more >
Create a Secure Chat Application with Socket.IO and React
The WebSocket protocol builds on top of the HTTP protocol to provide a persistent bi-directional connection between the client and the server.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found