[RTOP-24] Minor fix

This commit is contained in:
lucasbutzke
2025-07-10 14:35:27 -04:00
parent 4067ce939f
commit fbd3afe00a
2 changed files with 23 additions and 7 deletions
-3
View File
@@ -80,10 +80,7 @@ class CertGen():
print(f"Certificate saved to {cert_file}")
print(f"Private key saved to {key_file}")
# TODO update certificate on cliente before expiration
# TODO add a function to update the certificate on the client before expiration
# TODO add a function to check if the certificate is valid (not expired and not yet valid)
# TODO add a function to check if the certificate is already generated
def is_certificate_valid(self, cert_file):
"""
Checks if a certificate is valid (not expired and not yet valid).
+23 -4
View File
@@ -2595,9 +2595,19 @@ def run_https():
# Credentials already created
else:
print("Credentials already generated!")
context = ('/etc/ssl/certs/certOPENPLC.pem', '/etc/ssl/private/keyOPENPLC.pem')
app_restapi.run(debug=False, host='0.0.0.0', threaded=True, port=8443, ssl_context=context)
try:
context = ('/etc/ssl/certs/certOPENPLC.pem', '/etc/ssl/private/keyOPENPLC.pem')
app_restapi.run(debug=False, host='0.0.0.0', threaded=True, port=8443, ssl_context=context)
except KeyboardInterrupt as e:
print(f"Exiting OpenPLC Webserver...{e}")
openplc_runtime.stop_runtime()
except Exception as e:
print(f"An error occurred: {e}")
openplc_runtime.stop_runtime()
except:
print("An unexpected error occurred.")
# TODO handle file error
except FileNotFoundError as e:
print(f"Could not find SSL credentials! {e}")
@@ -2638,7 +2648,16 @@ def run_http():
configure_runtime()
monitor.parse_st(openplc_runtime.project_file)
app.run(debug=False, host='0.0.0.0', threaded=True, port=8080)
try:
app.run(debug=False, host='0.0.0.0', threaded=True, port=8080)
except KeyboardInterrupt as e:
print(f"Exiting OpenPLC Webserver...{e}")
openplc_runtime.stop_runtime()
except Exception as e:
print(f"An error occurred: {e}")
openplc_runtime.stop_runtime()
except:
print("An unexpected error occurred.")
except Error as e:
print("error connecting to the database" + str(e))