Skip to content

Latest commit

 

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimpleWs

Simple WebSocket and TLS implementation from scratch in Go.

SimpleWs is a learning-focused networking project that implements WebSocket (RFC 6455) and TLS 1.3 (RFC 8446) starting directly from a TCP connection. The project was built to understand how modern network communication works by implementing the protocols step by step rather than relying entirely on existing high-level libraries.

How This Works

when client intiates connection using the TLS protocol, first step is sending `Client Hello . this message allow the client to communicate its supported parameters to the server and begin the negotiation process.

In the ClientHello, the client offers the supported cipher suites, protocol versions, and various extensions. Some commonly used extensions include the Server Name Indication (SNI), which identifies the target hostname, and Key Share, which contains the client's key exchange parameters. The cipher suites indicate the algorithms used to encrypt the messages during the communication, while the Key Share is used to establish shared keys later through the key scheduling process.

After receiving the ClientHello, the server will respond with multiple messages, starting with the ServerHello. In the ServerHello, the server will choose which TLS version to use, which cipher suite to use, which compression method to use, and send the key share. However, in this project, for now, it only supports TLS_AES_128_GCM_SHA256 for the cipher suite and X25519 for the key exchange algorithm.

After that, now it is time to run the key schedule, which is detailed in RFC 8446 Section 7.1, because after sending the ServerHello, the next messages will be sent and received in encrypted form. In the first key schedule, we will get a key and IV for both the server and client, which are used for encrypting and decrypting messages.

How To Run

first edit the main.go file in the example and replace the certificate and private key path with the paths to your own certificate and private key

cd example
go build
./example

Goals

  • Understand networking from the TCP layer upward
  • Explore the TLS 1.3 protocol
  • Improve understanding of network protocols and their implementation in Go
  • Learn how WebSocket communication works
  • Build a simple foundation for secure WebSocket communication (WSS)

References

About

Simple Websocket and TLS Implementation from Scratch (Start from TCP) on Golang

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages