-
Notifications
You must be signed in to change notification settings - Fork 222
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
feat(iroh)!: switch TLS authentication to raw public keys #2937
Conversation
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/2937/docs/iroh/ Last updated: 2025-03-14T13:04:06Z |
For a hot minute I was imagining a feature on rustls to disable all non-RPK paths, imagining that we could get rid of ASN.1/DER parsing code. |
iroh-net/src/tls/resolver.rs
Outdated
use crate::tls::Authentication; | ||
|
||
#[derive(Debug)] | ||
pub(crate) struct AlwaysResolvesCert { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of annoying that rustls
has all the implementations for ResolvesClientCert
and ResolvesServerCert
that we need, but they're not all exposed.
There's
AlwaysResolvesClientCert
AlwaysResolvesServerCert
AlwaysResolvesClientRawPublicKeyCert
AlwaysResolvesServerRawPublicKeyCert
I'd rather not have to implement a trait outside the crate where it's defined, but eh.
Also it's super annoying that they split it up into client/server like that.
Going to wait with pushing this forward until we know if rustls/rustls#2258 might happen |
ed3d590
to
e44d964
Compare
9b7bb71
to
dfe0885
Compare
d21dffb
to
5d89fe3
Compare
looks like this is not happening, or at least not soon, so moving forward with this |
|
||
#[tokio::test] | ||
#[traced_test] | ||
async fn test_two_devices_roundtrip_quinn_rebinding_conn() -> Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. Are we sure we want to delete these tests?
I see it's weird to see a test that tests "quinn", but I think what this is actually doing is testing UdpConn
(without depending on iroh being correct).
Instead of deleting these, perhaps they should be renamed & moved to udp_conn.rs
?
iroh/src/tls.rs
Outdated
/// Error for generating iroh p2p TLS configs. | ||
/// TLS Authentication mechanism | ||
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)] | ||
pub enum Authentication { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally find it a little confusing if we have mod tls;
in lib.rs
, but then use pub enum
etc. here.
Can we make it pub(crate) enum
(and also the same with pub mod certificate etc.)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cleaned this up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This enum also should be pub(crate)
should it not?
98ad8d5
to
bb49ae7
Compare
40423a3
to
4f5e787
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with the changes, and I'd be down for this to get merged.
But I do wonder why you've removed 4 tests? Do you think they're not useful anymore? The tests are:
magicsock::test_two_devices_roundtrip_quinn_raw
magicsock::test_two_devices_roundtrip_quinn_rebinding_conn
magicsock::udp_conn::test_rebinding_conn_send_recv_ipv4
magicsock::udp_conn::test_rebinding_conn_send_recv_ipv6
I guess they're related to this PR because they use tls::make_client_config
and tls::make_server_config
. Was there some problem in getting them to work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can an external observer looking at intercepted datagrams distinguish which mechanism is used?
/// | ||
/// For details see the libp2p spec at <https://github.com/libp2p/specs/blob/master/tls/tls.md> | ||
/// | ||
/// This is the only mechanism available in `iroh@0.33.0` and earlier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also add that this method will be removed at some time in the future? Like to make it really clear that you should only use this to transition, but don't just use it and forget about it.
iroh/src/tls.rs
Outdated
/// Error for generating iroh p2p TLS configs. | ||
/// TLS Authentication mechanism | ||
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)] | ||
pub enum Authentication { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This enum also should be pub(crate)
should it not?
They were pretty painful to update, and I am not convinced of their usefulness tbh, as they don't really test much of our code anymore. But happy to hear other arguments |
My understanding is that as long as we don't have encrypted client hello, this is observable during the handshake |
Yeah I was about to write that.
|
03fac9c
to
ae45558
Compare
I have moved the test discussion into an issue, to not block merging this #3229 |
This is step 1 to land #2798
this was only used in tests, and those only tested quinn isolation things, which have been removed
Co-authored-by: Philipp Krüger <philipp.krueger1@gmail.com>
a5e653a
to
6bdbbf0
Compare
## Description This introduces the configuration of the TLS authentication method, allowing to enable the usage of raw public keys, which will lead to us being able to remove the hack of using self signed certificates. ## Breaking Changes By default iroh endpoints will now use the new `RawPublicKey` TLS configuration. This means they will not be able to talk to older iroh nodes. If needed, the old mechanism can still be used by configuring the endpoint like this ```rust let endpoint = Endpoint::builder() .tls_x509() // <--- this enables the old style TLS authentication // ... .bind(); ``` Closes #2798 ## Change checklist - [x] Self-review. - [x] Documentation updates following the [style guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text), if relevant. - [x] Tests if relevant. - [x] All breaking changes documented. --------- Co-authored-by: Philipp Krüger <philipp.krueger1@gmail.com>
Description
This introduces the configuration of the TLS authentication method, allowing to enable the usage of raw public keys, which will lead to us being able to remove the hack of using self signed certificates.
Breaking Changes
By default iroh endpoints will now use the new
RawPublicKey
TLS configuration. This means they will not be able to talk to older iroh nodes. If needed, the old mechanism can still be used by configuring the endpoint like thisCloses #2798
Change checklist