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

Added ability to use SSL for MQTT connections on port 443 #442

Merged
merged 3 commits into from Jun 13, 2023

Conversation

Marko298
Copy link
Contributor

@Marko298 Marko298 commented Jun 10, 2023

Hello, currently, if you try to use reverse proxy with SSL, you will face the issue that HomeUI will still try to use a WS connection over the HTTPS-served page to establish MQTT connection. Such behavior will cause the following error.

Mixed Content: The page at 'https://your-domain.com/' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://your-domain:443/mqtt'. This request has been blocked; this endpoint must be available over WSS.
v._doConnect @ main.640d40dd027f9102c521.js:2

After examining the code base, I found that the MQTT library supports WSS connection. We need to pass useSSL option as true.

if (this.connectOptions.useSSL) {

This PR adds the check if the current port is 443 and sets useSSL to true

@Marko298 Marko298 requested a review from a team as a code owner June 10, 2023 12:17
@sikmir
Copy link
Contributor

sikmir commented Jun 13, 2023

Doesn't work for me, I got Uncaught DOMException: The operation is insecure..

@Marko298
Copy link
Contributor Author

Ok, will try to launch ui somehow locally and test better

@Marko298
Copy link
Contributor Author

it works if you could somehow specify the port before it crashes

@webconn
Copy link
Contributor

webconn commented Jun 13, 2023

it works if you could somehow specify the port before it crashes

Maybe it will be better to force SSL by default if HTTPS is used and also try port 443 if default one is configured? Thus it will work both via HTTP (in local network) and via HTTPS reverse proxy automatically

@Marko298
Copy link
Contributor Author

Let me push the fix for empty screen first. Then I will try to implement your proposal

@Marko298
Copy link
Contributor Author

Done. Now it renders UI properly

@Marko298
Copy link
Contributor Author

Maybe it will be better to force SSL by default if HTTPS is used and also try port 443 if default one is configured? Thus it will work both via HTTP (in local network) and via HTTPS reverse proxy automatically

Done. Take a look please

@webconn webconn changed the base branch from master to external_prs June 13, 2023 13:07
Copy link
Contributor

@webconn webconn left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the contribution! We will increase version number and this package will appear in testing in an hour or so

@webconn webconn merged commit 0c69d8b into wirenboard:external_prs Jun 13, 2023
4 of 9 checks passed
@Marko298
Copy link
Contributor Author

Waiting to test 🔥

webconn added a commit that referenced this pull request Jun 14, 2023
Co-authored-by: Mark Boychuk <12628139+Marko298@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants