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

feat: Add WebTransport protocol based on BiagioFesta/wtransport #5701

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
e8f39b8
Wtransport usage
dgarus Nov 28, 2024
7a0a2fb
removed the Provider trait
dgarus Dec 9, 2024
a0c270f
Merge branch 'refs/heads/master' into use-wtransport
dgarus Dec 17, 2024
60b5c36
removed the Provider trait
dgarus Dec 17, 2024
f41e8fa
mod transport
dgarus Dec 20, 2024
b18c11e
connecting & noise usage
dgarus Dec 21, 2024
969cbc9
connection
dgarus Dec 23, 2024
57c7dcf
applied fmt
dgarus Dec 23, 2024
e0535d9
multiaddr tests
dgarus Dec 24, 2024
427ae0c
close listener test
dgarus Dec 25, 2024
c8cb4bd
close listener test
dgarus Dec 25, 2024
bf1bac4
Merge branch 'refs/heads/master' into use-wtransport
dgarus Dec 25, 2024
9f9a54d
fixed clippy
dgarus Dec 25, 2024
7b67199
added hashes to a multiaddr
dgarus Dec 26, 2024
47b1159
the first smoke test
dgarus Dec 28, 2024
9a77699
the first smoke test
dgarus Dec 28, 2024
867b332
Merge branch 'refs/heads/master' into use-wtransport
dgarus Dec 28, 2024
9dc6664
using quic transport configuration
dgarus Dec 28, 2024
21d242d
dial operation is not allowed
dgarus Jan 10, 2025
550c364
Merge branch 'refs/heads/master' into use-wtransport
dgarus Jan 11, 2025
73acbe5
fix config
dgarus Jan 13, 2025
2bf414f
using a session request rather than an incoming session
dgarus Jan 13, 2025
611a358
fmt
dgarus Jan 13, 2025
7b40aed
Merge branch 'master' into use-wtransport
dgarus Jan 13, 2025
7f67c80
Merge remote-tracking branch 'origin/use-wtransport' into use-wtransport
dgarus Jan 13, 2025
b10361f
smoke test
dgarus Jan 21, 2025
a30b7fd
Merge branch 'master' into use-wtransport
dgarus Jan 21, 2025
5dec225
smoke test
dgarus Jan 21, 2025
73ea5fe
fixed docs errors
dgarus Jan 21, 2025
c663674
fixed clippy errors
dgarus Jan 22, 2025
ef06dfb
fixed clippy errors
dgarus Jan 22, 2025
2ceb92f
fixed clippy errors
dgarus Jan 22, 2025
65112a9
fixed failed checks
dgarus Jan 22, 2025
160c4c4
fmt
dgarus Jan 22, 2025
84be643
tls changelog
dgarus Jan 22, 2025
a2ff738
webtransport version
dgarus Jan 22, 2025
579cf3e
webtransport version
dgarus Jan 22, 2025
f922a2a
fix review comments
dgarus Jan 22, 2025
6d40792
fixed clippy errors
dgarus Jan 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 131 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ members = [
"transports/websocket-websys",
"transports/websocket",
"transports/webtransport-websys",
"transports/webtransport",
"wasm-tests/webtransport-tests",
]
resolver = "2"
Expand Down Expand Up @@ -111,6 +112,7 @@ libp2p-webrtc-utils = { version = "0.4.0", path = "misc/webrtc-utils" }
libp2p-webrtc-websys = { version = "0.4.0", path = "transports/webrtc-websys" }
libp2p-websocket = { version = "0.45.0", path = "transports/websocket" }
libp2p-websocket-websys = { version = "0.5.0", path = "transports/websocket-websys" }
libp2p-webtransport = { version = "0.1.0", path = "transports/webtransport" }
libp2p-webtransport-websys = { version = "0.5.0", path = "transports/webtransport-websys" }
libp2p-yamux = { version = "0.47.0", path = "muxers/yamux" }

Expand Down
6 changes: 6 additions & 0 deletions transports/tls/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.7.0
dgarus marked this conversation as resolved.
Show resolved Hide resolved

- Added functions to generate a webtransport certificate,
to make webtransport server and client TLS configurations.
See [PR 5701](https://github.com/libp2p/rust-libp2p/pull/5701)

## 0.6.0

<!-- Update to libp2p-core v0.43.0 -->
Expand Down
1 change: 1 addition & 0 deletions transports/tls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ thiserror = { workspace = true }
webpki = { version = "0.101.4", package = "rustls-webpki", features = ["std"] }
x509-parser = "0.16.0"
yasna = "0.5.2"
time = "0.3"

# Exposed dependencies. Breaking changes to these are breaking changes to us.
[dependencies.rustls]
Expand Down
51 changes: 50 additions & 1 deletion transports/tls/src/certificate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

use std::sync::Arc;

use ::time::OffsetDateTime;
use libp2p_identity as identity;
use libp2p_identity::PeerId;
use x509_parser::{prelude::*, signature_algorithm::SignatureAlgorithm};
Expand Down Expand Up @@ -121,14 +122,62 @@ pub fn generate(
Ok((rustls_certificate, rustls_key))
}

pub fn generate_with_validity_period(
identity_keypair: &identity::Keypair,
not_before: OffsetDateTime,
not_after: OffsetDateTime,
) -> Result<
(
rustls::pki_types::CertificateDer<'static>,
rustls::pki_types::PrivateKeyDer<'static>,
dgarus marked this conversation as resolved.
Show resolved Hide resolved
),
GenError,
> {
// Keypair used to sign the certificate.
// SHOULD NOT be related to the host's key.
// Endpoints MAY generate a new key and certificate
// for every connection attempt, or they MAY reuse the same key
// and certificate for multiple connections.
let certificate_keypair = rcgen::KeyPair::generate(P2P_SIGNATURE_ALGORITHM)?;
let rustls_key = rustls::pki_types::PrivateKeyDer::from(
rustls::pki_types::PrivatePkcs8KeyDer::from(certificate_keypair.serialize_der()),
);

let certificate = {
let mut params = rcgen::CertificateParams::new(vec![]);
params.distinguished_name = rcgen::DistinguishedName::new();
params.custom_extensions.push(make_libp2p_extension(
identity_keypair,
&certificate_keypair,
)?);
params.alg = P2P_SIGNATURE_ALGORITHM;
params.key_pair = Some(certificate_keypair);
params.not_before = not_before;
params.not_after = not_after;
rcgen::Certificate::from_params(params)?
};

let rustls_certificate = rustls::pki_types::CertificateDer::from(certificate.serialize_der()?);

Ok((rustls_certificate, rustls_key))
}

/// Attempts to parse the provided bytes as a [`P2pCertificate`].
///
/// For this to succeed, the certificate must contain the specified extension and the signature must
/// match the embedded public key.
pub fn parse<'a>(
certificate: &'a rustls::pki_types::CertificateDer<'a>,
) -> Result<P2pCertificate<'a>, ParseError> {
let certificate = parse_unverified(certificate.as_ref())?;
parse_binary(certificate.as_ref())
}

/// Attempts to parse the provided bytes as a [`P2pCertificate`].
///
/// For this to succeed, the certificate must contain the specified extension and the signature must
/// match the embedded public key.
pub fn parse_binary(der_input: &[u8]) -> Result<P2pCertificate, ParseError> {
let certificate = parse_unverified(der_input)?;

certificate.verify()?;

Expand Down
Loading
Loading