Skip to content

St3viejr/Secure-File-Transfer-protocol-in-Python-using-SSL-TLS-security-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Secure File Transfer System (Python + SSL/TLS)

This project implements a secure client-server file transfer application using Python's built-in socket and ssl libraries.

Unlike standard file transfers (like basic FTP) that send data in cleartext, this application establishes an encrypted SSL/TLS tunnel before transmitting any file data. It demonstrates the implementation of Server-Authenticated TLS, where the client verifies the server's identity using a digital certificate.


Skills Demonstrated

  • Network Programming: TCP Socket communication (binding, listening, accepting connections).
  • Applied Cryptography: Implementing SSL/TLS contexts for data encryption in transit.
  • Public Key Infrastructure (PKI): Handling X.509 certificates (.crt) and private keys (.key).
  • Client-Server Architecture: Building a distinct server listener and client initiator.
  • File I/O: Binary reading and writing of files.

Project Structure

The repository contains the following essential files:

  • server.py: The server script. It binds to port 8443, wraps the socket in SSL using the private key/cert, and listens for requests.
  • client.py: The client script. It connects to the server, verifies the server's certificate, and requests the file.
  • server.crt: The public SSL Certificate (used by the server to prove identity, and by the client to verify it).
  • server.key: The server's Private Key (used to decrypt the handshake).
  • textfile.txt: The sample file to be transferred.

How to Run

Prerequisites: Python 3. (No external pip installs required).

Step 1: Setup

Ensure all files (server.py, client.py, keys, and textfile.txt) are in the same directory.

Step 2: Start the Server

Open a terminal in the project directory and run:

python server.py

Step 3: Start the Client

Open a separate terminal window in the same directory and run:

python client.py

Step 4: Verify Success

Client Terminal: You will see Downloaded file successfully. for file textfile.txt.

Server Terminal: You will see Connection from... and Server has sent the file....

Directory: A new file named downloaded_textfile.txt will appear in your folder.


Security Details

Encryption: All data transferred is encrypted using TLS. If a packet sniffer (like Wireshark) intercepted the traffic, the file contents would be unreadable.

Authentication: The client code uses context.load_verify_locations('server.crt'). This ensures the client is connecting to the intended server and not a "Man-in-the-Middle" attacker.

Secure Context: The server creates an SSL context with ssl.create_default_context(ssl.Purpose.CLIENT_AUTH), ensuring modern security protocols are used for the handshake.


Security Note

Educational Use Only: This repository includes the server.key (Private Key) for demonstration purposes so the code can be run immediately. In a real-world deployment, the private key must remain secret and never be uploaded to a version control system (GitHub).

About

Demonstration of SSL/TLS security

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages