Giter VIP home page Giter VIP logo

mranv / tls.rs Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 39 KB

A simple Rust-based TCP client-server application with SSL/TLS encryption and real-time data transmission. The server sends data to the client in real-time, and the client prints the received data. The communication is secured using public/private key authentication with tokio and rustls.

Rust 100.00%
rust tcp tls async encyption real-time-communication ssl

tls.rs's Introduction

tls.rs : Secure TCP Client-Server in Rust

This repository contains a simple implementation of a secure TCP client-server application in Rust. The communication between the client and the server is secured using SSL/TLS with public/private key configuration. The server sends data to the client in real-time, and the client prints this data as it is received.

Features

  • Asynchronous TCP communication using tokio.
  • SSL/TLS encryption using native-tls and tokio-native-tls.
  • Public/private key authentication.
  • Real-time data transmission from server to client.

Requirements

  • Rust (latest stable version)
  • OpenSSL (for generating certificates)

Setup

Generate Certificates

To run the server and client, you need to generate the necessary certificates and keys. You can use OpenSSL to generate these files.

  1. Generate a private key:

    openssl genrsa -out key.pem 2048
  2. Generate a certificate signing request (CSR):

    openssl req -new -key key.pem -out cert.csr
  3. Generate a self-signed certificate:

    openssl x509 -req -days 365 -in cert.csr -signkey key.pem -out cert.pem
  4. Convert the key and certificate to PKCS#12 format:

    openssl pkcs12 -export -out identity.pfx -inkey key.pem -in cert.pem

    Use password when prompted for an export password.

Running the Server

  1. Navigate to the server directory:

    cd server
  2. Ensure you have the required dependencies:

    cargo build --release
  3. Run the server:

    cargo run --release

Running the Client

  1. Navigate to the client directory:

    cd client
  2. Ensure you have the required dependencies:

    cargo build --release
  3. Run the client:

    cargo run --release

Project Structure

tls.rs
├── certs
│   ├── cert.csr
│   ├── cert.pem
│   ├── identity.pfx
│   └── key.pem
├── client
│   ├── Cargo.lock
│   ├── Cargo.toml
│   └── src
│       └── main.rs
├── README.md
└── server
    ├── Cargo.lock
    ├── Cargo.toml
    └── src
        └── main.rs
  • certs/: Directory containing the certificate and key files.
  • client/: Directory containing the client implementation.
    • Cargo.toml: Client dependencies.
    • src/main.rs: Main client implementation.
  • server/: Directory containing the server implementation.
    • Cargo.toml: Server dependencies.
    • src/main.rs: Main server implementation.
  • README.md: This readme file.

tls.rs's People

Contributors

mranv avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.