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

fix(tls): fix rustls panic due to critical libp2p extension #5498

Merged
merged 6 commits into from
Jul 18, 2024

Conversation

arpankapoor
Copy link
Contributor

Description

Resolves #5487.

Notes & open questions

While parsing a certificate, rustls-webpki throws up a UnsupportedCriticalExtension if the certificate has any non-standard TLS extensions that are marked critical.
Since the libp2p TLS extension spec says This extension MAY be marked critical, not marking the extension as critical should be okay.

Ideally, the certificate consistency check added upstream should probably ignore non-critical errors like this.

If this seems like an acceptable solution, I'll add in a changelog entry.

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

Copy link
Member

@jxs jxs left a comment

Choose a reason for hiding this comment

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

Hi, and thanks a lot for digging into this! ❤️
This change acceptable to me, can you add the CHANGELOG.md entry?
What I don't understand is, why are we havingwebpki trying to parse the libp2p extension?

@arpankapoor
Copy link
Contributor Author

As per my understanding, this upstream change added a new check to verify the consistency of the certificate. It does so by parsing the CertificateDer in order to extract its public key and compare with the public key extracted from the SigningKey.

@jxs
Copy link
Member

jxs commented Jul 17, 2024

Hi @arpankapoor sorry to be back to this, but wdyt of implementing the suggestion mentioned on rustls/rustls#1918 (comment) and therefore being able to continue setting it to critical?

@arpankapoor
Copy link
Contributor Author

yeah, that's a better solution. I've implemented it for both the client and server certs.

@arpankapoor arpankapoor changed the title fix(tls): mark libp2p extension as non-critical to prevent panic fix(tls): fix rustls panic due to critical libp2p extension Jul 18, 2024
jxs
jxs previously approved these changes Jul 18, 2024
Copy link
Member

@jxs jxs left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks Arpan!

@jxs jxs added the send-it label Jul 18, 2024
@mergify mergify bot dismissed jxs’s stale review July 18, 2024 13:55

Approvals have been dismissed because the PR was updated after the send-it label was applied.

@mergify mergify bot merged commit 1617abb into libp2p:master Jul 18, 2024
72 checks passed
@jxs
Copy link
Member

jxs commented Jul 18, 2024

released libp2p-tls 0.4.1

@DougAnderson444
Copy link
Contributor

Thank you! This was driving me nuts debugging .with_quic.

matheus23 added a commit to n0-computer/iroh that referenced this pull request Aug 12, 2024
TimTinkers pushed a commit to unattended-backpack/rust-libp2p that referenced this pull request Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

InvalidCertificate(Other(OtherError(UnsupportedCriticalExtension))) error with [email protected]
3 participants