mirror of
https://github.com/thiagoralves/OpenPLC_v3.git
synced 2026-02-06 02:02:20 +08:00
Use explicit SSLContext for better socket handling on Windows/MSYS2
Replace tuple-based ssl_context with explicit ssl.SSLContext creation using PROTOCOL_TLS_SERVER and load_cert_chain(). This follows Python ssl module best practices and may handle socket configuration more robustly on MSYS2 where sockets may default to non-blocking mode. The tuple shortcut (cert, key) internally creates an SSLContext, but using an explicit SSLContext gives us better control and follows the documented approach for server-side SSL. This may help with the errno 11 (Resource temporarily unavailable) issue on Windows/MSYS2. If this doesn't resolve the issue, we'll need to investigate more invasive solutions like wrapping Werkzeug's socket creation. Co-Authored-By: Thiago Alves <thiagoralves@gmail.com>
This commit is contained in:
@@ -2672,7 +2672,8 @@ def run_https():
|
||||
print("Credentials already generated!")
|
||||
|
||||
try:
|
||||
context = (str(CERT_FILE), str(KEY_FILE))
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
|
||||
context.load_cert_chain(certfile=str(CERT_FILE), keyfile=str(KEY_FILE))
|
||||
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}")
|
||||
|
||||
Reference in New Issue
Block a user