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

Muxer selection in security handshake #446

Merged
merged 56 commits into from
Dec 12, 2022
Merged

Conversation

julian88110
Copy link
Contributor

This spec describes a feature that carries out muxer selection in the security handshake process.

Copy link
Contributor

@marten-seemann marten-seemann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a good start, thank you @julian88110!

Not sure if I was supposed to review it yet, so I just added some high-level comments.

connections/muxer-sel-in-sec-handshake.md Outdated Show resolved Hide resolved
connections/muxer-sel-in-sec-handshake.md Outdated Show resolved Hide resolved
connections/muxer-sel-in-sec-handshake.md Outdated Show resolved Hide resolved
connections/muxer-sel-in-sec-handshake.md Outdated Show resolved Hide resolved
connections/muxer-sel-in-sec-handshake.md Outdated Show resolved Hide resolved
Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid first specification proposal @julian88110! Thank you for the write-up!

connections/muxer-sel-in-sec-handshake.md Outdated Show resolved Hide resolved
@julian88110 julian88110 marked this pull request as ready for review September 12, 2022 21:58
Copy link
Contributor

@MarcoPolo MarcoPolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! I think we should have a Go implementation before merging this, since I think that will uncover some subtleties we probably want to mention.

Also I think the exact steps in the noise handshake are still a little fuzzy for me.

connections/muxer-sel-in-sec-handshake.md Outdated Show resolved Hide resolved
connections/muxer-sel-in-sec-handshake.md Outdated Show resolved Hide resolved
connections/muxer-sel-in-sec-handshake.md Outdated Show resolved Hide resolved
connections/muxer-sel-in-sec-handshake.md Outdated Show resolved Hide resolved
connections/muxer-sel-in-sec-handshake.md Outdated Show resolved Hide resolved
Update Noise handshake section, Revise muxer string in examples.
@marten-seemann
Copy link
Contributor

@julian88110 The Noise Extension Registry (#453) was merged. You can rebase this PR now, and add an extension entry for the muxer selection.

@marten-seemann
Copy link
Contributor

I updated spec and condensed it down a bit. @mxinden and @MarcoPolo, can I ask you for a review?

Copy link
Member

@p-shahi p-shahi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly nits

connections/inlined-muxer-negotiation.md Outdated Show resolved Hide resolved
connections/inlined-muxer-negotiation.md Outdated Show resolved Hide resolved
connections/inlined-muxer-negotiation.md Outdated Show resolved Hide resolved
connections/inlined-muxer-negotiation.md Outdated Show resolved Hide resolved
connections/inlined-muxer-negotiation.md Outdated Show resolved Hide resolved
connections/inlined-muxer-negotiation.md Outdated Show resolved Hide resolved
connections/inlined-muxer-negotiation.md Outdated Show resolved Hide resolved
connections/inlined-muxer-negotiation.md Outdated Show resolved Hide resolved
noise/README.md Show resolved Hide resolved
connections/README.md Show resolved Hide resolved
@marten-seemann marten-seemann dismissed their stale review December 6, 2022 23:36

I took over this PR.

Copy link
Contributor

@elenaf9 elenaf9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of questions. Apologies if they have already been discussed or if the answers are obvious. Parts of this are still new to me.

Comment on lines 65 to 67
this document use `"libp2p"` for their ALPN. If `"libp2p"` is the result of the
ALPN process, nodes MUST use multistream negotiation of the stream multiplexer
as described in [connections].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per connection spec, both sides can initiate the protocol negotiation.
I think the server SHOULD NOT initiate a protocol negotiation if it already knows that it doesn't support any of the client's muxers.

The client can't differentiate between whether the server doesn't support early muxer negotiation, or whether it doesn't support any of the its muxers.
In case of the latter it would do an unnecessary multistream negotiation attempt just to then still fail. We could add an extra item to signal that none of the protocols are supported. But not sure if its worth the complexity.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, in case of noise we fail if no common muxer is supported. Sorry if this is a stupid question, but why don't we also fail the TLS handshake in that case?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to enable backwards-compatibility with legacy implementations. With these nodes, the result of the negotiation process will be "libp2p", so we need to do multistream.
Now we could say that we fail the handshake if there's anything other than "libp2p" in the list, but this would make it impossible to deploy a listener that speaks HTTP and libp2p without this optimization.

connections/inlined-muxer-negotiation.md Outdated Show resolved Hide resolved
connections/inlined-muxer-negotiation.md Outdated Show resolved Hide resolved
Comment on lines +64 to +65
According to [TLS], nodes that don't implement the optimization described in
this document use `"libp2p"` for their ALPN. If `"libp2p"` is the result of the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I am missing something this is not true: the TLS spec does not specify what ALPN to use.
Also: if we add libp2p over http as drafted in #477 we could also have the "h2" APLN here, no?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you could accept HTTP and libp2p at the same time. That's WebTransport does, by the way.
Negotiating HTTP though means that after completing the handshake, you're in HTTP land, not in libp2p land any more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I am missing something this is not true: the TLS spec does not specify what ALPN to use.

Good catch. Both Go and Rust do this. @marten-seemann can you add it to the TLS spec? Either in this pull request or a separate one?

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the comment above on documenting the default libp2p ALPN, this specification is good to merge from my end.

Thanks again for the document 🙏

(Corresponding tracking issue in rust-libp2p: libp2p/rust-libp2p#2994)

Comment on lines +64 to +65
According to [TLS], nodes that don't implement the optimization described in
this document use `"libp2p"` for their ALPN. If `"libp2p"` is the result of the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I am missing something this is not true: the TLS spec does not specify what ALPN to use.

Good catch. Both Go and Rust do this. @marten-seemann can you add it to the TLS spec? Either in this pull request or a separate one?

@marten-seemann marten-seemann merged commit 41d5104 into master Dec 12, 2022
@marten-seemann marten-seemann deleted the MuxerSel-inSecHandshake branch December 12, 2022 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exchange muxer info in security handshake
6 participants