Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websocket: WSS instead of WS if page is accessed via HTTPS #2937

Merged
merged 2 commits into from
Dec 31, 2024

Conversation

helgeklein
Copy link
Contributor

Prevents mixed content errors in the browser by selecting WSS or WS for the websocket depending on the page's scheme (HTTPS or HTTP).

This fixes the problem described in issue 2396.

Prevents mixed content errors in the browser by selecting WSS or WS for the websocket depending on the page's scheme (HTTPS or HTTP).
Copy link
Contributor

@sfeilmeier sfeilmeier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@sfeilmeier sfeilmeier merged commit f231934 into OpenEMS:develop Dec 31, 2024
@helgeklein
Copy link
Contributor Author

Hi @sfeilmeier, I just upgraded my FEMS system to version 2025.1.2 but this fix is not being used. Instead, the backend URL is still built statically with unencryted WS:// only:

url: 'ws://' + location.hostname + (location.port ? ':' + location.port : '') + '/websocket'

@Sn0w3y
Copy link
Contributor

Sn0w3y commented Feb 2, 2025

Hi @sfeilmeier, I just upgraded my FEMS system to version 2025.1.2 but this fix is not being used. Instead, the backend URL is still built statically with unencryted WS:// only:

url: 'ws://' + location.hostname + (location.port ? ':' + location.port : '') + '/websocket'

Are you sure it is using ws:// to Backend?

This is from my FEMS and i guess it is either local EDGE to UI or the config does not reflect the wss:// to Fenecon.

Screenshot_20250203_004628_Chrome.jpg

@clehne
Copy link
Contributor

clehne commented Feb 3, 2025

Hi @Sn0w3y, I think WS is the preferred way here. WSS is added via e.g. nginx proxy functionality. This has several advantages, e.g. minimisation of attack surface, more up to date security fixes. Easier certificate handing,...

@Sn0w3y
Copy link
Contributor

Sn0w3y commented Feb 3, 2025

Hi @clehne - this is just a Snippet (Screenshot) from a FEMS we have in our Account :D

@sfeilmeier
Copy link
Contributor

@helgeklein: OpenEMS UI uses themes for different production stylings. OpenEMS only has ui/src/themes/openems/environments/*.ts files; additionally every distributor of an OpenEMS based EMS adds an individual theme with his own URLs.

@helgeklein
Copy link
Contributor Author

@Sn0w3y The ctrlBackend0 setting of my Fenecon device shows the same WSS URL as on your screenshot: wss://www1.fenecon.de:443/openems-backend2.

However, my issue (and fix) are about something different: they're about how the JavaScript code in the browser talks to the Fenecon device in my house. And that latter communication is still happening unencrypted via WS.

@helgeklein
Copy link
Contributor Author

@helgeklein: OpenEMS UI uses themes for different production stylings. OpenEMS only has ui/src/themes/openems/environments/*.ts files; additionally every distributor of an OpenEMS based EMS adds an individual theme with his own URLs.

Thanks, @sfeilmeier. How can the URL template be changed in the theme used by Fenecon?

@helgeklein
Copy link
Contributor Author

Hi @sfeilmeier, will the Fenecon theme be updated to include this change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants