scar-chat/README.md

5.1 KiB

SCAR Chat Application

A cross-platform GUI chat client and server with SSL/TLS encryption, built in C++.

Features

Server (chat_server)

  • Listens on TCP port 42317 with TLS/SSL encryption
  • Multi-client support with broadcast messaging
  • Uses OpenSSL for secure communication
  • Linux/cross-platform compatible

Qt Client (chat_client_qt)

  • Cross-platform GUI using Qt5/6 Widgets
  • TLS/SSL encrypted connection to server
  • Customizable UI:
    • Background color selector for all windows
    • Chat text color customization
    • Transparency/opacity slider (0-100%)
  • Message history display
  • Real-time message sending and receiving
  • Linux/cross-platform compatible

Windows Client (chat_client_win)

  • Native Win32 GUI client
  • Same UI features as Qt client
  • Windows-only build

Prerequisites

Linux / macOS

# Ubuntu/Debian
sudo apt-get install cmake qtbase5-dev libssl-dev build-essential

# macOS (Homebrew)
brew install cmake qt5 openssl

Windows

  • Visual Studio 2019+ or MinGW
  • CMake 3.16+
  • Qt5/6 SDK
  • OpenSSL for Windows (vcpkg or prebuilt binaries)

Building

Linux / macOS

  1. Create and generate certificates:

    cd certs
    ./generate_certs.sh
    cd ..
    
  2. Build the project:

    mkdir build
    cd build
    cmake ..
    make
    
  3. Install (optional):

    make install
    

Windows

  1. Generate certificates (use OpenSSL for Windows or WSL):

    cd certs
    # On Windows, use Git Bash or WSL to run generate_certs.sh
    # Or generate manually using OpenSSL
    cd ..
    
  2. Build:

    mkdir build
    cd build
    cmake -G "Visual Studio 16 2019" ..
    cmake --build . --config Release
    

Running

Server

# Linux / macOS
./build/chat_server certs/server.crt certs/server.key

# Windows
.\build\Release\chat_server.exe certs\server.crt certs\server.key

The server will listen on localhost:42317.

Qt Client

# Linux / macOS
./build/chat_client_qt

# Windows (if built on Windows)
.\build\Release\chat_client_qt.exe

Connect to server by entering host/port and clicking "Connect".

Windows Client

# Windows only
.\build\Release\chat_client_win.exe

Customization Features

Background Color

  • Click "BG Color" button to select background color for all windows
  • Color choice is applied immediately

Text Color

  • Click "Text Color" button to select chat text color
  • Updates chat display in real-time

Transparency

  • Use the transparency slider (0-100%) to adjust window opacity
  • 0% = fully transparent, 100% = fully opaque

SSL/TLS Certificates

Generate Self-Signed Certificates

For development and testing:

cd certs

# Generate private key
openssl genrsa -out server.key 2048

# Generate certificate (valid for 365 days)
openssl req -new -x509 -key server.key -out server.crt -days 365 \
  -subj "/C=US/ST=State/L=City/O=SCAR/CN=localhost"

cd ..

Note: For production, use certificates signed by a trusted Certificate Authority (CA).

Ignoring Self-Signed Certificates

The Qt client is configured to ignore self-signed certificate errors during development:

socket->ignoreSslErrors();

For production, implement proper certificate validation.

Project Structure

scar-chat/
├── CMakeLists.txt          # Top-level CMake configuration
├── README.md               # This file
├── certs/                  # SSL certificates directory
│   └── generate_certs.sh   # Certificate generation script
├── src/
│   ├── server/
│   │   └── server.cpp      # TLS server (OpenSSL)
│   ├── qt_client/
│   │   └── main.cpp        # Qt GUI client
│   └── windows_client/
│       └── main_win.cpp    # Win32 GUI client
└── build/                  # Build output directory (created after cmake)

Troubleshooting

"Connection refused" error

  • Ensure server is running on the same host/port
  • Check firewall settings on port 42317

SSL/TLS errors

  • Verify certificates exist in certs/ directory
  • Regenerate certificates if expired or corrupted
  • Ensure certificate and key files are readable

Qt not found during CMake

# Set Qt path explicitly
cmake -DQt5_DIR=/path/to/Qt5/lib/cmake/Qt5 ..

OpenSSL not found during CMake

# Set OpenSSL path explicitly (macOS example)
cmake -DOPENSSL_DIR=/usr/local/opt/openssl ..

Development Notes

  • C++17 standard is required
  • Qt5/6 for cross-platform GUI
  • OpenSSL 1.1+ for TLS/SSL
  • Threading used for non-blocking socket operations
  • Message protocol: simple newline-delimited UTF-8 text

Security Considerations

  • Uses TLS 1.2+ for encrypted communication
  • ⚠️ Development mode: ignores self-signed certificate errors
  • ⚠️ No user authentication implemented
  • ⚠️ No message encryption at application level (relies on TLS)

For production use, implement:

  • Proper certificate validation
  • User authentication and authorization
  • Message signing/verification
  • Rate limiting and DoS protection

License

This project is provided as-is for educational and development purposes.