Refactor RSA client and server structure: remove old files, add main.py, and update Dockerfiles for new entry points

This commit is contained in:
Lukian 2025-01-21 12:02:48 +01:00
parent 27c37167d6
commit 6b7c09324f
6 changed files with 28 additions and 23 deletions

View file

@ -2,4 +2,4 @@ FROM python:alpine
WORKDIR /app
COPY . .
RUN pip install -r requirements.txt
CMD ["python", "client.py"]
CMD ["python", "main.py"]

View file

@ -1,2 +1,3 @@
flask==3.1.0
pyopenssl==25.0.0
pyopenssl==25.0.0
requests==2.26.0

View file

@ -1,20 +0,0 @@
import ssl
from flask import *
import flask_wtf as wtf
print(ssl.OPENSSL_VERSION)
context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
context.load_cert_chain(certfile='ssl/CA.crt', keyfile='ssl/CA.key')
app= Flask(__name__)
@app.route("/")
def index():
return render_template("index.html")
@app.route('/data', methods=['POST'])
def receiv():
encrypted_data = request.form['data']
if __name__ == "__main__":
app.run(ssl_context=context)

View file

@ -3,5 +3,6 @@ WORKDIR /app
COPY . .
RUN pip install -r requirements.txt
EXPOSE 80
EXPOSE 443
EXPOSE 5000
CMD ["python", "__init__.py"]
CMD ["python", "main.py"]

23
RSA/server/main.py Normal file
View file

@ -0,0 +1,23 @@
import ssl
from flask import Flask, render_template, request
app = Flask(__name__)
app.config['SECRET_KEY'] = 'your_secret_key_here' # Required for Flask-WTF
# SSL Configuration
context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
context.load_cert_chain(certfile='ssl/CA.crt', keyfile='ssl/CA.key')
@app.route("/")
def index():
return render_template("index.html")
@app.route('/data', methods=['POST'])
def receive():
encrypted_data = request.form.get('data', None) # Safely get form data
if encrypted_data:
return f"Received encrypted data: {encrypted_data}", 200
return "No data received", 400
if __name__ == "__main__":
app.run(ssl_context=context, host='0.0.0.0', port=5000) # Allow external access