libp2p / js-libp2p

The JavaScript Implementation of libp2p networking stack.
https://libp2p.io
Other
2.29k stars 438 forks source link

Lacking Documentation: certhash for webRTC? #2438

Closed sleep9 closed 5 months ago

sleep9 commented 5 months ago

I am trying to establish a direct webRTC connection to a server (which is also a circuit relay server) but documentation is lacking on how to derive the certhash from a pem self signed certificate. I can establish RTC connection to another client connected to the server but cannot open a connection to the server itself, I can only speculate that it is due to lacking a listen address which requires a certhash.

See this discussion for more information https://github.com/libp2p/js-libp2p/discussions/2406

Severity:

Low

achingbrain commented 5 months ago

There are two flavours of WebRTC in libp2p - WebRTC and WebRTC Direct.

certhash is only used by WebRTC Direct which is dial-only in browsers and unimplemented in Node.js.

To implement it, changes would be necessary in libdatachannel which would make the implementation more complicated - see https://github.com/paullouisageneau/libdatachannel/issues/970

Node.js can listen on (and dial) a regular WebRTC address, but it requires a relay server to do the initial SDP handshake.

An alternative is to have Node.js listen on a WebSocket address, then it can be dialled from browsers.

The WebRTC transport readme was lacking docs for this - I've updated it, please take a look and open a PR if you think it can be improved - https://github.com/libp2p/js-libp2p/tree/main/packages/transport-webrtc#readme