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

move go-libp2p-webtransport to p2p/transport/webtransport #1737

Merged
merged 54 commits into from
Sep 7, 2022

Conversation

marten-seemann
Copy link
Contributor

Part of #1717.

To make this actually secure, we still need to verify the certificate
hashes.
With the most recent webtransport-go, it's not necessary to block any more.
Copy link
Collaborator

@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.

Some small comments/questions.

Nothing blocking if we agree we can change the multiaddr quic/webtransport part later, but if we are committing to this right now I think we should take a bit more. Not saying we need to change it later, just that we agree we could change it.

type certManager struct {
clock clock.Clock
ctx context.Context
ctxCancel context.CancelFunc
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe this is an anti-pattern. https://go.dev/blog/context-and-structs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, this is also the pattern we've been using all across go-libp2p, in every service that spawns Go routines. It's super convenient since you can call the CancelFunc multiple times (which you can't do if you do the naive implementation with a closeChan chan struct{}, as you can only close a channel once).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah I know we do it a lot. Just worth pointing out that I don’t think it’s idiomatic go, and maybe we should stop adding new code like this.

Not a blocking change of course

p2p/transport/webtransport/cert_manager.go Outdated Show resolved Hide resolved
p2p/transport/webtransport/conn.go Outdated Show resolved Hide resolved
if err != nil {
return err
}
// TODO: is this the best (and complete?) way to identify RSA certificates?
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think anything with the pkcs-1 oid should probably be checked here (You aren't matching oidSignatureSHA512WithRSA for example) (https://www.rfc-editor.org/rfc/rfc3279#section-2.3.1)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure how to check for this. We only have access to the parsed certificate, where the signature algorithm is encoded as a x509.SignatureAlgorithm. I'd assume that those other algorithms would show up as x509.UnknownSignatureAlgorithm. Maybe it's sufficient to reject that one?

p2p/transport/webtransport/multiaddr.go Show resolved Hide resolved
p2p/transport/webtransport/transport.go Outdated Show resolved Hide resolved
p2p/transport/webtransport/listener.go Show resolved Hide resolved
p2p/transport/webtransport/listener.go Outdated Show resolved Hide resolved
p2p/transport/webtransport/listener.go Outdated Show resolved Hide resolved
p2p/transport/webtransport/transport.go Outdated Show resolved Hide resolved
@MarcoPolo
Copy link
Collaborator

I left a comment instead of an approval. I think another blocker is the potential stalling of the http server. If that's addressed as well as the other comment (quic/webtransport) then I think this is good and the rest of the changes can be done in separate PRs.

@marten-seemann
Copy link
Contributor Author

@MarcoPolo Thank you for the comprehensive review! I've addressed all your comments and recreated this PR.

Nothing blocking if we agree we can change the multiaddr quic/webtransport part later, but if we are committing to this right now I think we should take a bit more. Not saying we need to change it later, just that we agree we could change it.

See my comment here: #1737 (comment).

@marten-seemann marten-seemann merged commit d934c56 into master Sep 7, 2022
@marten-seemann marten-seemann deleted the merge-webtransport branch November 8, 2022 13:59
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.

2 participants