Skip to content
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

go-js echo / plaintext fails to send message #1110

Closed
gitaaron opened this issue Jan 9, 2022 · 7 comments
Closed

go-js echo / plaintext fails to send message #1110

gitaaron opened this issue Jan 9, 2022 · 7 comments
Assignees
Labels
P2 Medium: Good to have, but can wait until someone steps up

Comments

@gitaaron
Copy link

gitaaron commented Jan 9, 2022

  • Version: 0.35.8
  • Platform: Darwin [REDACTED]-Mac-mini.local 20.5.0 Darwin Kernel Version 20.5.0: Sat May 8 05:10:31 PDT 2021; root:xnu-7195.121.3~9/RELEASE_ARM64_T8101 arm64
  • Subsystem: Insecure

Severity: Medium

Description:

I tried to dial the JS echo listener example from the Go echo dialer example and vice versa over plaintext and in both cases it failed during the handshake.

It seems that the Data property of the pubkey in Exchange is inconsistent where Go simply uses the marshalled value of the encrypted public key and JS includes the entire pubkey object re-encoded as a protobuf.

There also seems to be an issue with the samples themselves where the Go sample uses newline to signify the end of a message and JS does not.

Steps to reproduce the error:

  1. Change 'noise' in the js example to 'plaintext'.
  2. In the JS sample folder run > node listener
  3. In the Go sample folder run > ./echo -l 9012 -d /ip4/127.0.0.1/tcp/10333/p2p/QmcrQZ6RJdpYuGvZqD5QEHAv6qX4BrQLJLQPQUrTrzdcgm -insecure
@gitaaron gitaaron added the need/triage Needs initial labeling and prioritization label Jan 9, 2022
@lidel
Copy link
Member

lidel commented Feb 18, 2022

@gitaaron what is the problem / use case you are trying to solve?

@gitaaron
Copy link
Author

hi @lidel thanks for looking at this! The use case is to assist in development/debugging go-js interop issues.

Here is a little more context in case it is helpful. I was looking at go-js webrtc interop which I believe is still an issue tagged with help wanted.

To assist myself in debugging the problem I figured it might help to look at the traffic over wireshark. This is when I discovered the go-js interop issue over plaintext (more specifically the discrepancy in the exchange object passed).

So I figured I might create a new issue and submit a PR with the fix in case someone else might also find it useful.

I am new to libp2p so your feedback/advice is appreciated.

@wemeetagain
Copy link
Member

linked to #1111

@mpetrunic
Copy link
Member

Triage notes: @gitaaron could you try with latest version and Plaintext encryption?

@mpetrunic mpetrunic added need/author-input Needs input from the original author and removed need/triage Needs initial labeling and prioritization labels Nov 15, 2022
@gitaaron
Copy link
Author

Unfortunately, still not working for me.

When I try to dial from Go to JS over plaintext echo I see the following error msg in Go -

  * [/ip4/127.0.0.1/tcp/10333] failed to negotiate security protocol: proto: required field "Type" not set

When I try to dial JS to Go I see the following error message -

[AggregateError: All promises were rejected] {
  [errors]: [
    InvalidCryptoExchangeError: Remote did not provide its public key
        at encrypt (file:///Users/asurty/POpen/libp2p/workspace-js-libp2p/js-libp2p/dist/src/insecure/index.js:58:15)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
        at async Plaintext.secureOutbound (file:///Users/asurty/POpen/libp2p/workspace-js-libp2p/js-libp2p/dist/src/insecure/index.js:81:16)
        at async DefaultUpgrader._encryptOutbound (file:///Users/asurty/POpen/libp2p/workspace-js-libp2p/js-libp2p/dist/src/upgrader.js:447:20)
        at async DefaultUpgrader.upgradeOutbound (file:///Users/asurty/POpen/libp2p/workspace-js-libp2p/js-libp2p/dist/src/upgrader.js:184:21)
        at async TCP.dial (file:///Users/asurty/POpen/libp2p/workspace-js-libp2p/js-libp2p/node_modules/@libp2p/tcp/dist/src/index.js:50:22)
        at async DefaultTransportManager.dial (file:///Users/asurty/POpen/libp2p/workspace-js-libp2p/js-libp2p/dist/src/transport-manager.js:77:20)
        at async DialRequest.dialAction (file:///Users/asurty/POpen/libp2p/workspace-js-libp2p/js-libp2p/dist/src/connection-manager/dialer/index.js:175:20)
        at async file:///Users/asurty/POpen/libp2p/workspace-js-libp2p/js-libp2p/dist/src/connection-manager/dialer/dial-request.js:67:28
        at async Promise.any (index 0) {
      code: 'ERR_ENCRYPTION_FAILED'
    }
  ]
}

Last I looked into it there was a mismatch in the protobuf 'Exchange' message where on the JS side the 'pubkey' seemed to be nested as an additional Exchange.

@github-actions
Copy link
Contributor

Oops, seems like we needed more information for this issue, please comment with more details or this issue will be closed in 7 days.

@mpetrunic mpetrunic added P2 Medium: Good to have, but can wait until someone steps up and removed need/author-input Needs input from the original author kind/stale labels Nov 29, 2022
@mpetrunic mpetrunic moved this to Weekly Candidates/Discuss in js-libp2p Nov 29, 2022
@p-shahi p-shahi added this to the Best Effort Track milestone Dec 6, 2022
@p-shahi p-shahi moved this from 🥞Weekly Candidates/Discuss🎙 to 🧊Icebox🥶 in js-libp2p Jan 24, 2023
@wemeetagain
Copy link
Member

Closing as stale

@github-project-automation github-project-automation bot moved this from 🧊Icebox🥶 to 🎉Done in js-libp2p Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 Medium: Good to have, but can wait until someone steps up
Projects
Archived in project
Development

No branches or pull requests

6 participants