diff --git a/RSA/client/dockerfile b/RSA/client/dockerfile index 288c0d8..42a27ac 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", "client.py"] \ No newline at end of file +CMD ["python", "main.py"] \ No newline at end of file diff --git a/RSA/client/client.py b/RSA/client/main.py similarity index 100% rename from RSA/client/client.py rename to RSA/client/main.py diff --git a/RSA/client/requirements.txt b/RSA/client/requirements.txt index a27eef0..d76f48f 100644 --- a/RSA/client/requirements.txt +++ b/RSA/client/requirements.txt @@ -1,2 +1,3 @@ flask==3.1.0 -pyopenssl==25.0.0 \ No newline at end of file +pyopenssl==25.0.0 +requests==2.26.0 \ No newline at end of file diff --git a/RSA/server/__init__.py b/RSA/server/__init__.py deleted file mode 100644 index 9083498..0000000 --- a/RSA/server/__init__.py +++ /dev/null @@ -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) diff --git a/RSA/server/dockerfile b/RSA/server/dockerfile index b201e6a..b673dbb 100644 --- a/RSA/server/dockerfile +++ b/RSA/server/dockerfile @@ -3,5 +3,6 @@ WORKDIR /app COPY . . RUN pip install -r requirements.txt EXPOSE 80 +EXPOSE 443 EXPOSE 5000 -CMD ["python", "__init__.py"] \ No newline at end of file +CMD ["python", "main.py"] \ No newline at end of file diff --git a/RSA/server/main.py b/RSA/server/main.py new file mode 100644 index 0000000..48237f9 --- /dev/null +++ b/RSA/server/main.py @@ -0,0 +1,23 @@ +import ssl +from flask import Flask, render_template, request + +app = Flask(__name__) +app.config['SECRET_KEY'] = 'c&S2QL9DDhZjwlqPoRYRGSN6gOidjaC9f25CW#SF1AinsMg7$3*JxC3e^9FnuliC5DWfhAPwiPcAMJcutBn#5k&VsIP0KBOMf9VvzKTN@Wuuq5i*UjoonTZEMHiyabpI' # 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