A simple, SSL-enabled server/client application written in Python using asyncio and ssl.
- Asynchronous server and client communication
- SSL encryption for secure data transfer
- JWT-based authentication
- PostgreSQL database integration
- Automatic SSL certificate generation
src/
│
├── ssl/
│ ├── cert.pem
│ ├── key.pem
├── client.py
├── testing.py
├── openssl.cnf
├── requirements.txt
├── dbConnection.py
└── server.py
ssl/: Contains SSL certificate (cert.pem) and key (key.pem)client.py: Asyncio-based client implementationopenssl.cnf: OpenSSL configuration for certificate generationrequirements.txt: Project dependenciesdbConnection.py: Database connection and table initializationserver.py: Main server code handling connections, JWT, and verificationtesting.py: Main testing, runs withpytest
- Python 3.8+
- Dependencies (installed via
requirements.txt):- asyncio
- ssl
- os
- subprocess
- pyjwt
- python-dotenv
- asyncpg
-
Clone the repository:
git clone https://github.com/yourusername/matrix.git cd matrix -
Install dependencies:
bin/install
-
Set up environment variables: Create a
.envfile in the project root and add:DATABASE_URL=<your-postgresql-connection-string>
bin/startpython client.pyThe client will establish an SSL connection with the server, receive a JWT token, and can then send authenticated messages.
The server automatically generates SSL certificates if not present in the ssl/ directory, using the openssl.cnf configuration.
- Clients receive a JWT token upon connection, valid for 1 hour
- The server verifies the JWT token with each communication
- Clients are notified upon token expiration
- Utilizes Neon DB (PostgreSQL)
- Initializes connection and creates
UsersandMessagestables on server start
- SSL encryption ensures secure data transfer
- JWT tokens provide stateless authentication
- Automatic certificate generation enhances ease of deployment
Contributions are welcome! Please feel free to submit a Pull Request. Run ruff check and pytest before pushing.
This project is licensed under the MIT License.