Encrypting NodeJS and Socket.IO data

I was wondering if there is someone who can show me the correct way to end my chat.

I have a website where you can log into your account and I want to use live chat. The solution I found would be NodeJS with Socket.io, but I am getting into a problem.

eg. You send a message to John as follows: You are the server - enter a "message" with parameters such as its id, etc. - john has socket.on ("message") and receives it.

You can only connect to the node server with the IP server node.

  • But how can I prevent someone from hijacking the conversation by creating it in one file and connecting to the node server and waiting for the "message" event.

  • Is there a way to encrypt the connection to the node js server?

  • Or can I prevent the client from only connecting from the site to the server?

  • Should I encrypt all messages with Private, the public key?

  • If so, how?

  • How can I secure communication in a NodeJS chat?

Thank you for all the suggestions and responses. Peter

+3


source to share


1 answer


Socket.IO allows you to set up authentication for new sessions. You can do this using a cookie, or using JSON web tokens for example . The authentication mechanism has changed from 0.9 to 1.0 , so just be aware of this when you google it.



As far as encryption is concerned, as long as you are using https you should be fine. Trying to implement your own encryption scheme instead of using https is more risky and works anyway.

+5


source







All Articles