This is RuChat a rust based web server that uses websockets for real time communications.
Endpoints:
/: Entry point/api/login: POST: login handling/api/register: POST: Registring handlingwss://x.x.x.x:2121/: Websocket endpoint/js/*: GET: Serving js files/css/*: GET: Serving css
To use the project just clone the repository setup local TLS/SSL certs and build it via cargo in release mode :
$ git clone git@github.com:NasriAnis/ruchat.git
$ cd ruchat
To enable secure WebSocket (wss://) and HTTPS connections for local development, your browser requires valid TLS certificates. Using mkcert is the recommended approach, as it creates a trusted local Certificate Authority that browsers will automatically accept.
We have provided an automated setup script (setup_certs.sh) to handle this configuration effortlessly.
What the Setup Script Does: The setup_certs.sh script automates the tedious configuration steps by:
- Checking Requirements: Ensuring mkcert is installed on your local system before running.
- Root Authority Registration: Installing a unique local Certificate Authority (CA) straight into your system and browser root stores (including Firefox, Chrome, and Brave).
- Certificate Generation: Automatically creating a secure certificate valid for localhost, 127.0.0.1, and ::1.
- Project Structuring: Dropping them cleanly into a ./certs/ directory and renaming them to cert.pem and key.pem to match our Rust application configuration.
- Security Enforcement: Checking for a .gitignore file and appending your private key (key.pem) to ensure it's never accidentally leaked to version control.
How to Run It:
$ chmod +x setup_certs.sh
$ ./setup_certs.sh
$ cargo build --release
$ cargo run --release
After running the script new certificates will be saved inside the mkcert directory to delete those just run this command:
$ rm -rf "$(mkcert -CAROOT)"