Debian Codegraph @

debian/patches/upgrade-rustls.patch

raw symbols SCIP
1 From: Peter Michael Green <[email protected]>
2 From: Maytham Alsudany <[email protected]>
3 Forwarded: not-needed
4 Description: Upgrade rustls
5 Also replaces webpki-roots with rustls-native-certs.
6
7 --- a/Cargo.toml
8 +++ b/Cargo.toml
9 @@ -39,17 +39,19 @@
10 version = "0.3.5"
11
12 [dependencies.rustls]
13 -version = "0.21"
14 +version = "0.23"
15 +default-features = false
16 +features = ["ring", "logging", "std", "tls12"]
17
18 [dependencies.rustls-pemfile]
19 -version = "1.0"
20 +version = "2"
21
22 [dependencies.rustls-webpki]
23 -version = "0.101.4"
24 +version = "0.102"
25 optional = true
26
27 -[dependencies.webpki-roots]
28 -version = "0.22.3"
29 +[dependencies.rustls-native-certs]
30 +version = "0.8"
31 optional = true
32
33 [dev-dependencies.async-std]
34 @@ -67,7 +69,7 @@
35 version = "1"
36
37 [features]
38 -client = ["webpki-roots"]
39 +client = ["rustls-native-certs"]
40 default = [
41 "client",
42 "server",
43 --- a/src/connector.rs
44 +++ b/src/connector.rs
45 @@ -3,7 +3,8 @@
46 use crate::client;
47
48 use futures_io::{AsyncRead, AsyncWrite};
49 -use rustls::{ClientConfig, ClientConnection, OwnedTrustAnchor, RootCertStore, ServerName};
50 +use rustls::pki_types::ServerName;
51 +use rustls::{ClientConfig, ClientConnection, RootCertStore};
52 use std::convert::TryFrom;
53 use std::future::Future;
54 use std::io;
55 @@ -65,15 +66,9 @@
56 impl Default for TlsConnector {
57 fn default() -> Self {
58 let mut root_certs = RootCertStore::empty();
59 - root_certs.add_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|ta| {
60 - OwnedTrustAnchor::from_subject_spki_name_constraints(
61 - ta.subject,
62 - ta.spki,
63 - ta.name_constraints,
64 - )
65 - }));
66 + let result = rustls_native_certs::load_native_certs().expect("Failed to load system root certificates");
67 + root_certs.add_parsable_certificates(result);
68 let config = ClientConfig::builder()
69 - .with_safe_defaults()
70 .with_root_certificates(root_certs)
71 .with_no_client_auth();
72 Arc::new(config).into()
73 @@ -118,7 +113,7 @@
74 F: FnOnce(&mut ClientConnection),
75 {
76 let domain = match ServerName::try_from(domain.as_ref()) {
77 - Ok(domain) => domain,
78 + Ok(domain) => domain.to_owned(),
79 Err(_) => {
80 return Connect(ConnectInner::Error(Some(io::Error::new(
81 io::ErrorKind::InvalidInput,
82 --- a/src/rusttls/test_stream.rs
83 +++ b/src/rusttls/test_stream.rs
84 @@ -4,9 +4,10 @@
85 use futures_util::io::{AsyncReadExt, AsyncWriteExt};
86 use futures_util::task::{noop_waker_ref, Context};
87 use futures_util::{future, ready};
88 +use rustls::pki_types::{PrivateKeyDer, ServerName};
89 use rustls::{
90 - Certificate, ClientConfig, ClientConnection, ConnectionCommon, PrivateKey, RootCertStore,
91 - ServerConfig, ServerConnection, ServerName,
92 + ClientConfig, ClientConnection, ConnectionCommon, RootCertStore,
93 + ServerConfig, ServerConnection,
94 };
95 use rustls_pemfile::{certs, pkcs8_private_keys};
96 use std::convert::TryFrom;
97 @@ -223,12 +224,10 @@
98 const CHAIN: &str = include_str!("../../tests/end.chain");
99 const RSA: &str = include_str!("../../tests/end.rsa");
100
101 - let cert = certs(&mut BufReader::new(Cursor::new(CERT))).unwrap();
102 - let cert = cert.into_iter().map(Certificate).collect();
103 - let mut keys = pkcs8_private_keys(&mut BufReader::new(Cursor::new(RSA))).unwrap();
104 - let key = PrivateKey(keys.pop().unwrap());
105 + let cert = certs(&mut BufReader::new(Cursor::new(CERT))).map(|c| c.unwrap()).collect::<Vec<_>>();
106 + let mut keys = pkcs8_private_keys(&mut BufReader::new(Cursor::new(RSA))).map(|c| c.unwrap()).collect::<Vec<_>>();
107 + let key = PrivateKeyDer::from(keys.pop().unwrap());
108 let sconfig = ServerConfig::builder()
109 - .with_safe_defaults()
110 .with_no_client_auth()
111 .with_single_cert(cert, key)
112 .unwrap();
113 @@ -236,11 +235,10 @@
114
115 let domain = ServerName::try_from("localhost").unwrap();
116 let mut root_store = RootCertStore::empty();
117 - let chain = certs(&mut BufReader::new(Cursor::new(CHAIN))).unwrap();
118 - let (added, ignored) = root_store.add_parsable_certificates(&chain);
119 + let chain = certs(&mut BufReader::new(Cursor::new(CHAIN))).map(|c| c.unwrap()).collect::<Vec<_>>();
120 + let (added, ignored) = root_store.add_parsable_certificates(chain);
121 assert!(added >= 1 && ignored == 0);
122 let cconfig = ClientConfig::builder()
123 - .with_safe_defaults()
124 .with_root_certificates(root_store)
125 .with_no_client_auth();
126 let client = ClientConnection::new(Arc::new(cconfig), domain);