Secure HTTP Server with Self-Signed Certificate (Python) This project demonstrates how to create an HTTP server and secure it with HTTPS using a self-signed certificate in Python. Prerequisites
Python 3.6+ OpenSSL Wireshark Git Visual Studio Code (recommended)
Setup Instructions
Clone the repository:git clone cd secure-http-server-python
Set up a virtual environment:python -m venv venv source venv/bin/activate # Linux/macOS venv\Scripts\activate # Windows
Generate self-signed certificate:openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes
Run the server:python server.py
Access the server: Open https://localhost:8443 in a browser. Accept the security warning for the self-signed certificate.
Capturing TLS Handshake with Wireshark
Open Wireshark and select the network interface (e.g., lo for localhost). Set a capture filter: tcp.port == 8443. Start capturing packets. Access https://localhost:8443 in a browser. Stop the capture and save screenshots of the TLS handshake packets.
Project Structure
server.py: HTTPS server implementation. .gitignore: Ignores venv, key.pem, cert.pem, and Python cache files. README.md: Project documentation. wireshark_instructions.md: TLS handshake capture guide. screenshots/: TLS handshake screenshots.
Notes
The self-signed certificate triggers a browser warning, which is expected. Do not commit key.pem or cert.pem to GitHub.