1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
Description: use crate rustls-native-certs (not webpki-roots)
Author: Jonas Smedegaard <dr@jones.dk>
Forwarded: not-needed
Last-Update: 2024-02-17
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -27,5 +27,5 @@
futures-util = { version = "0.3.1", features = [ "io" ] }
lazy_static = "1"
rustls-pemfile = "2"
-webpki-roots = "0.26"
+rustls-native-certs = "0.6"
webpki = { version = "0.102", package = "rustls-webpki", default-features = false }
--- a/tests/badssl.rs
+++ b/tests/badssl.rs
@@ -3,6 +3,8 @@
use std::net::ToSocketAddrs;
use std::sync::Arc;
use futures_util::io::{AsyncReadExt, AsyncWriteExt};
+use rustls::pki_types::CertificateDer;
+use rustls_native_certs::load_native_certs;
use smol::net::TcpStream;
use futures_rustls::{
client::TlsStream,
@@ -36,8 +38,10 @@
#[cfg(feature = "tls12")]
fn test_tls12() -> io::Result<()> {
let fut = async {
- let root_store = rustls::RootCertStore {
- roots: webpki_roots::TLS_SERVER_ROOTS.iter().cloned().collect(),
+ let mut root_store = rustls::RootCertStore::empty();
+ for cert in load_native_certs().expect("could not load platform certs") {
+ root_store.add(CertificateDer::from_slice(&cert.0))
+ .expect("could not add certificate");
};
let config = rustls::ClientConfig::builder_with_protocol_versions(&[&rustls::version::TLS12])
.with_root_certificates(root_store)
@@ -69,8 +73,10 @@
#[test]
fn test_modern() -> io::Result<()> {
let fut = async {
- let root_store = rustls::RootCertStore {
- roots: webpki_roots::TLS_SERVER_ROOTS.iter().cloned().collect(),
+ let mut root_store = rustls::RootCertStore::empty();
+ for cert in load_native_certs().expect("could not load platform certs") {
+ root_store.add(CertificateDer::from_slice(&cert.0))
+ .expect("could not add certificate");
};
let config = rustls::ClientConfig::builder()
.with_root_certificates(root_store)
|