
Hackers don't have to be too smart unless you do this
I wanted to share a cool and easy system to make your applications safer. This tutorial is focused on WebSocket-like systems, but you can apply the same concept elsewhere. The idea is universal. The Main Issue If you have a WebSocket server, you've probably asked yourself: How does the server know if a client is from your application and not some wacky person who just spun up a WebSocket client at 3 am and is now knocking on your door? (knock knock, twin) Good news: there are several ways to handle this. Let me introduce nonce signature verification . The Solution You define a secret key that only your application and your server know. Think of it as a shared password that never actually travels through the wire. Secret key: XDDCC When a client connects to the server, the server generates and sends a nonce , which is a random blob of bytes that's only valid once (hence the name). Nonce: emEdkZ The client must then sign the nonce using the secret key via HMAC-SHA256: Key Nonce Signature
Continue reading on Dev.to
Opens in a new tab



