Skip to content

Commit 8474385

Browse files
authored
Merge pull request #270 from kpcyrd/native-certs
Add native-certs support
2 parents 10d1147 + 070b93a commit 8474385

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ yaml = ["yaml_config"]
3838
proxy = ["tokio-socks"]
3939

4040
tls-native = ["native-tls", "tokio-native-tls"]
41-
tls-rust = ["tokio-rustls", "webpki-roots", "rustls-pemfile"]
41+
tls-rust = ["rustls-native-certs", "rustls-pemfile", "tokio-rustls", "webpki-roots"]
4242
encoding = ["dep:encoding", "irc-proto/encoding"]
4343

4444
[dependencies]
@@ -65,9 +65,10 @@ tokio-socks = { version = "0.5.1", optional = true }
6565

6666
# Feature - TLS
6767
native-tls = { version = "0.2.11", optional = true }
68-
tokio-rustls = { version = "0.26.0", optional = true }
69-
rustls-pemfile = { version = "2", optional = true }
7068
tokio-native-tls = { version = "0.3.1", optional = true }
69+
rustls-native-certs = { version = "0.8", optional = true }
70+
rustls-pemfile = { version = "2", optional = true }
71+
tokio-rustls = { version = "0.26.0", optional = true }
7172
webpki-roots = { version = "0.26.0", optional = true }
7273

7374

src/client/conn.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,15 @@ impl Connection {
341341
.with_custom_certificate_verifier(Arc::new(DangerousAcceptAllVerifier::new()));
342342
make_client_auth!(builder)
343343
} else {
344-
let mut root_store = webpki_roots::TLS_SERVER_ROOTS
345-
.iter()
346-
.cloned()
347-
.collect::<RootCertStore>();
344+
let mut root_store = RootCertStore::empty();
345+
346+
#[cfg(feature = "webpki-roots")]
347+
root_store.extend(webpki_roots::TLS_SERVER_ROOTS.iter().cloned());
348+
349+
let native_certs = rustls_native_certs::load_native_certs();
350+
for cert in native_certs.certs {
351+
root_store.add(cert.into())?;
352+
}
348353

349354
if let Some(cert_path) = config.cert_path() {
350355
if let Ok(file) = File::open(cert_path) {

0 commit comments

Comments
 (0)