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

update rustls to latest version #2107

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
88 changes: 68 additions & 20 deletions Cargo.lock

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

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ async-std = "1.6"
tokio = "1.21"
tokio-native-tls = "0.3.0"
tokio-openssl = "0.6.0"
tokio-rustls = "0.24.0"
tokio-rustls = "0.25.0"
tokio-util = "0.7.9"
parking_lot = "0.12"


# ssl
native-tls = "0.2"
openssl = "0.10.55"
rustls = "0.21.8"
rustls-native-certs = "0.6.3"
rustls-pemfile = "1.0.0"
webpki-roots = "0.25.0"
rustls = "0.22.0"
rustls-native-certs = "0.7"
rustls-pemfile = "2"
webpki-roots = "0.26"
ring = "0.17"


Expand Down
2 changes: 1 addition & 1 deletion crates/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dns-over-https-rustls = [
"rustls",
"hickory-proto/dns-over-https-rustls",
]
dns-over-https = ["hickory-proto/dns-over-https"]
dns-over-https = ["rustls", "hickory-proto/dns-over-https"]

dns-over-quic = ["dns-over-rustls", "hickory-proto/dns-over-quic"]

Expand Down
2 changes: 1 addition & 1 deletion crates/proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dns-over-https-rustls = ["dns-over-https"]
dns-over-https = ["bytes", "h2", "http", "dns-over-rustls", "tokio-runtime"]
dns-over-quic = [
"quinn",
"rustls/quic",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

"rustls",
"dns-over-rustls",
"bytes",
"tokio-runtime",
Expand Down
20 changes: 7 additions & 13 deletions crates/proto/src/h2/h2_client_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ where
.expect("programming error, tls should not be None here");
let name_server_name = Arc::clone(&tls.dns_name);

match tls.dns_name.as_ref().try_into() {
match tls.dns_name.as_ref().to_owned().try_into() {
Ok(dns_name) => {
let tls = TlsConnector::from(tls.client_config);
let tls = tls.connect(dns_name, AsyncIoStdAsTokio(tcp));
Expand Down Expand Up @@ -746,7 +746,7 @@ mod tests {
#[cfg(all(feature = "native-certs", not(feature = "webpki-roots")))]
{
let (added, ignored) = root_store
.add_parsable_certificates(&rustls_native_certs::load_native_certs().unwrap());
.add_parsable_certificates(rustls_native_certs::load_native_certs().unwrap());

if ignored > 0 {
warn!(
Expand All @@ -760,19 +760,13 @@ mod tests {
}
}
#[cfg(feature = "webpki-roots")]
root_store.add_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.iter().map(|ta| {
rustls::OwnedTrustAnchor::from_subject_spki_name_constraints(
ta.subject,
ta.spki,
ta.name_constraints,
)
}));
root_store.extend(
webpki_roots::TLS_SERVER_ROOTS
.iter()
.map(|ta| ta.to_owned()),
);

let mut client_config = ClientConfig::builder()
.with_safe_default_cipher_suites()
.with_safe_default_kx_groups()
.with_safe_default_protocol_versions()
.unwrap()
.with_root_certificates(root_store)
.with_no_client_auth();

Expand Down
20 changes: 10 additions & 10 deletions crates/proto/src/h3/h3_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ use h3::server::{Connection, RequestStream};
use h3_quinn::{BidiStream, Endpoint};
use http::Request;
use quinn::{EndpointConfig, ServerConfig};
use rustls::{server::ServerConfig as TlsServerConfig, version::TLS13, Certificate, PrivateKey};
use rustls::{
pki_types::{CertificateDer, PrivateKeyDer},
server::ServerConfig as TlsServerConfig,
version::TLS13,
};

use crate::{error::ProtoError, udp::UdpSocket};

Expand All @@ -29,8 +33,8 @@ impl H3Server {
/// Construct the new Acceptor with the associated pkcs12 data
pub async fn new(
name_server: SocketAddr,
cert: Vec<Certificate>,
key: PrivateKey,
cert: Vec<CertificateDer<'static>>,
key: PrivateKeyDer<'static>,
) -> Result<Self, ProtoError> {
// setup a new socket for the server to use
let socket = <tokio::net::UdpSocket as UdpSocket>::bind(name_server).await?;
Expand All @@ -40,14 +44,10 @@ impl H3Server {
/// Construct the new server with an existing socket
pub fn with_socket(
socket: tokio::net::UdpSocket,
cert: Vec<Certificate>,
key: PrivateKey,
cert: Vec<CertificateDer<'static>>,
key: PrivateKeyDer<'static>,
) -> Result<Self, ProtoError> {
let mut config = TlsServerConfig::builder()
.with_safe_default_cipher_suites()
.with_safe_default_kx_groups()
.with_protocol_versions(&[&TLS13])
.expect("TLS1.3 not supported")
let mut config = TlsServerConfig::builder_with_protocol_versions(&[&TLS13])
.with_no_client_auth()
.with_single_cert(cert, key)?;

Expand Down
19 changes: 9 additions & 10 deletions crates/proto/src/quic/quic_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
use std::{io, net::SocketAddr, sync::Arc};

use quinn::{Connection, Endpoint, ServerConfig};
use rustls::{server::ServerConfig as TlsServerConfig, version::TLS13, Certificate, PrivateKey};
use rustls::{
pki_types::{CertificateDer, PrivateKeyDer},
version::TLS13,
};

use crate::{error::ProtoError, udp::UdpSocket};

Expand All @@ -26,8 +29,8 @@ impl QuicServer {
/// Construct the new Acceptor with the associated pkcs12 data
pub async fn new(
name_server: SocketAddr,
cert: Vec<Certificate>,
key: PrivateKey,
cert: Vec<CertificateDer<'static>>,
key: PrivateKeyDer<'static>,
) -> Result<Self, ProtoError> {
// setup a new socket for the server to use
let socket = <tokio::net::UdpSocket as UdpSocket>::bind(name_server).await?;
Expand All @@ -37,14 +40,10 @@ impl QuicServer {
/// Construct the new server with an existing socket
pub fn with_socket(
socket: tokio::net::UdpSocket,
cert: Vec<Certificate>,
key: PrivateKey,
cert: Vec<CertificateDer<'static>>,
key: PrivateKeyDer<'static>,
) -> Result<Self, ProtoError> {
let mut config = TlsServerConfig::builder()
.with_safe_default_cipher_suites()
.with_safe_default_kx_groups()
.with_protocol_versions(&[&TLS13])
.expect("TLS1.3 not supported")
let mut config = TlsServerConfig::builder_with_protocol_versions(&[&TLS13])
.with_no_client_auth()
.with_single_cert(cert, key)?;

Expand Down
3 changes: 1 addition & 2 deletions crates/proto/src/quic/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,9 @@ async fn test_quic_stream() {
// now construct the client
let mut roots = rustls::RootCertStore::empty();
ca.iter()
.try_for_each(|ca| roots.add(ca))
.try_for_each(|ca| roots.add(ca.to_owned()))
.expect("failed to build roots");
let mut client_config = ClientConfig::builder()
.with_safe_defaults()
.with_root_certificates(roots)
.with_no_client_auth();

Expand Down
Loading
Loading