diff --git a/RSA/client/main.py b/RSA/client/client.py similarity index 100% rename from RSA/client/main.py rename to RSA/client/client.py diff --git a/RSA/client/dockerfile b/RSA/client/dockerfile index 42a27ac..288c0d8 100644 --- a/RSA/client/dockerfile +++ b/RSA/client/dockerfile @@ -2,4 +2,4 @@ FROM python:alpine WORKDIR /app COPY . . RUN pip install -r requirements.txt -CMD ["python", "main.py"] \ No newline at end of file +CMD ["python", "client.py"] \ No newline at end of file diff --git a/RSA/client/requirements.txt b/RSA/client/requirements.txt index d76f48f..a27eef0 100644 --- a/RSA/client/requirements.txt +++ b/RSA/client/requirements.txt @@ -1,3 +1,2 @@ flask==3.1.0 -pyopenssl==25.0.0 -requests==2.26.0 \ No newline at end of file +pyopenssl==25.0.0 \ No newline at end of file diff --git a/RSA/server/__init__.py b/RSA/server/__init__.py new file mode 100644 index 0000000..9083498 --- /dev/null +++ b/RSA/server/__init__.py @@ -0,0 +1,20 @@ +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) diff --git a/RSA/server/dockerfile b/RSA/server/dockerfile index b673dbb..b201e6a 100644 --- a/RSA/server/dockerfile +++ b/RSA/server/dockerfile @@ -3,6 +3,5 @@ WORKDIR /app COPY . . RUN pip install -r requirements.txt EXPOSE 80 -EXPOSE 443 EXPOSE 5000 -CMD ["python", "main.py"] \ No newline at end of file +CMD ["python", "__init__.py"] \ No newline at end of file diff --git a/RSA/server/main.py b/RSA/server/main.py deleted file mode 100644 index 93c1654..0000000 --- a/RSA/server/main.py +++ /dev/null @@ -1,23 +0,0 @@ -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