-
Notifications
You must be signed in to change notification settings - Fork 29
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
feat: add support WSS #54
base: main
Are you sure you want to change the base?
Conversation
example_app/src/main.rs
Outdated
// Setup a CryptoProvider to be able to use wss | ||
match rustls::crypto::ring::default_provider().install_default() { | ||
Ok(()) => {} // Do nothing crypto provider install successful | ||
Err(_) => log::warn!("failed to install CryptoProvider"), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this strictly required to connect over wss:/
? If so, we should maybe add it to ewebsock
proper (perhaps opt-in), or at least document it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is strictly required to have a provider to connect to WSS. That's a good idea. It would need to be feature flagged so users can disable it if they want to user a different provider. I can do a PR for that if you think that's a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm was looking over my comment and found the error message looked wrong. It was wrong. I used https instead of wss. https still works correctly in the browser but not native. I commented out the code you referenced above and... it still worked. So I went back to main and tried again and... it's back to not working on native (the browser still works). It panics on with the following message on native: thread 'ewebsock' panicked at /home/one/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustls-0.23.7/src/cr
ypto/mod.rs:260:14:
no process-level CryptoProvider available -- call CryptoProvider::install_default() before this point
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace I honestly don't really understand but it seems I only need to bring in the dependency and that's sufficient for it to work so that's easy and I just put it directly into I also added documentation for the tls feature to the best of my ability, not sure if it had been intentionally not documented. Let me know if you want me to squash the commits. I should also mention that there is another provider but I didn't try that one as it sounded more complicated in their docs. |
Not sure if this is useful but sharing it in case someone else might find it of value. If you do not think it is a good fit, please feel free to close the PR no hard feelings. I wanted to test connecting to secured endpoints and needed this modification to do it.