Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Add support for secure web sockets by using the TLS options when creating a server for the websockets.
Motivation and Context
When adding the httpsProtocol configuration in the serverless.yml file
serverless-offline will show the endpoints as https://localhost:3000/{default*} for HTTP and wss://localhost:3001 for WebSockets, as opposed to http:// and ws://
While https works with the certificates, the websocket protocol is not upgraded and uses http rather than https
How Has This Been Tested?
To test:
wscat -c wss://localhost:3001
wscat will complain because it can't establish a TLS/SSL connection, however using
wscat -c ws://localhost:3001
will work because it's not secure. Although this is unintended (since the protocol is listed as wss) and unusable if you're using serverless-offline with https and want to communicate with the websocket from a front-end because any browser will refuse to allow a connection to a non-secure server if using https.I've tested this with the version 8.8.0 since I couldn't figure out how to build master right now, but the code for the websocket server hasn't changed.
Also the code is the same as for the http event's http server since hapi's API is the same for both.
Cheers!