Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Commit

Permalink
Disable dials to multiaddrs without certhashes (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoPolo authored Dec 2, 2022
1 parent e76b7ae commit 3f9a285
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ class WebTransport implements Transport {

const { url, certhashes, remotePeer } = parseMultiaddr(ma)

if (certhashes.length === 0) {
throw new Error('Expected multiaddr to contain certhashes')
}

const wt = new window.WebTransport(`${url}/.well-known/libp2p-webtransport?type=noise`, {
serverCertificateHashes: certhashes.map(certhash => ({
algorithm: 'sha-256',
Expand Down
2 changes: 1 addition & 1 deletion test/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe('libp2p-webtransport', () => {
await node.start()

const err = await expect(node.dial(ma)).to.eventually.be.rejected()
expect(err.errors[0].toString()).to.contain('WebTransportError: Opening handshake failed.')
expect(err.errors[0].toString()).to.contain('Expected multiaddr to contain certhashes')

await node.stop()
})
Expand Down

0 comments on commit 3f9a285

Please sign in to comment.