-
Notifications
You must be signed in to change notification settings - Fork 446
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
Add Secure WebSockets example #930
Conversation
The problem is in here: https://github.com/libp2p/js-libp2p-websockets/blob/master/src/listener.js#L71 When we "reconstruct" the addresses that we are listening on in websockets transport, we have We should in |
(triage note) this looks good, but needs libp2p/js-libp2p-websockets#130 to ship first. |
Hi @vasco-santos, sorry for the lack of response and thanks for the PR! |
@D4nte we just shipped |
Looks much better, thanks! Unfortunately it fails due to the certificate being self-signed:
I am basing my test on the one in libp2p-websocket. But it does not seem to be the case as I tried both: const { stream } = await node2.dialProtocol(node1.peerId, '/print', { websocket: { rejectUnauthorized: false } }) and const { stream } = await node2.dialProtocol(node1.peerId, '/print', { rejectUnauthorized: false }) What am I missing? |
@D4nte the problem here is the following: By default, when libp2p discovers a peer (and has less than the minimum connections configured in connMgr) it will attempt to dial the peer. This way, when Consequently, when you trigger the dial manually This should not happen in production, as a self signed certificate should not happen. There are two solutions for this example:
Probably the second solution is cleaner, given that we do not change the default config of libp2p |
Actually, the only way for the test to work is to disable the Line 147 in 06e8f3d
|
That is true, good catch. We can live with that for now. One of the plans with #744 is to get rid of this autoDial strategy and have the node be more intelligent on finding out the nodes it should connect to. |
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.
LGTM, thanks for the example and to report the issue
@vasco-santos looking back at this, is it possible to pass |
Adding an example on how to use
wss
as it seems possible.