Skip to content

Commit

Permalink
fix non-desktop tls roots (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
neonphog authored May 13, 2024
1 parent 705c73a commit 8f76229
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 36 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

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

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ panic = "abort"

[workspace.dependencies]
# workspace member deps
sbd-bench = { version = "0.0.2-alpha", path = "rust/sbd-bench" }
sbd-client = { version = "0.0.2-alpha", path = "rust/sbd-client" }
sbd-e2e-crypto-client = { version = "0.0.2-alpha", path = "rust/sbd-e2e-crypto-client" }
sbd-o-bahn-client-tester = { version = "0.0.2-alpha", path = "rust/sbd-o-bahn-client-tester" }
sbd-o-bahn-server-tester = { version = "0.0.2-alpha", path = "rust/sbd-o-bahn-server-tester" }
sbd-server = { version = "0.0.2-alpha", path = "rust/sbd-server" }
sbd-bench = { version = "0.0.3-alpha", path = "rust/sbd-bench" }
sbd-client = { version = "0.0.3-alpha", path = "rust/sbd-client" }
sbd-e2e-crypto-client = { version = "0.0.3-alpha", path = "rust/sbd-e2e-crypto-client" }
sbd-o-bahn-client-tester = { version = "0.0.3-alpha", path = "rust/sbd-o-bahn-client-tester" }
sbd-o-bahn-server-tester = { version = "0.0.3-alpha", path = "rust/sbd-o-bahn-server-tester" }
sbd-server = { version = "0.0.3-alpha", path = "rust/sbd-server" }
# crate deps
anstyle = "1.0.6"
base64 = "0.22.0"
Expand Down
2 changes: 1 addition & 1 deletion rust/sbd-bench/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sbd-bench"
version = "0.0.2-alpha"
version = "0.0.3-alpha"
edition = "2021"

[dependencies]
Expand Down
6 changes: 5 additions & 1 deletion rust/sbd-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sbd-client"
version = "0.0.2-alpha"
version = "0.0.3-alpha"
description = "simple websocket-based message relay client"
license = "MIT OR Apache-2.0"
repository = "https://github.com/holochain/sbd"
Expand All @@ -23,6 +23,7 @@ tokio-tungstenite = { workspace = true, default-features = false, features = [ "
# optional
ed25519-dalek = { workspace = true, features = [ "rand_core" ], optional = true }
rand = { workspace = true, optional = true }
webpki-roots = { workspace = true, optional = true }

[target.'cfg(not(any(target_os = "windows", target_os = "linux", target_os = "macos")))'.dependencies]
webpki-roots = { workspace = true }
Expand All @@ -44,5 +45,8 @@ crypto = [ "dep:ed25519-dalek", "dep:rand" ]
# expose the raw client (used in server test suite)
raw_client = []

# force webpki roots instead of native certs
force_webpki_roots = [ "dep:webpki-roots" ]

[package.metadata.docs.rs]
all-features = true
30 changes: 12 additions & 18 deletions rust/sbd-client/src/raw_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,27 +210,21 @@ fn priv_system_tls(
) -> Arc<rustls::ClientConfig> {
let mut roots = rustls::RootCertStore::empty();

#[cfg(not(any(
target_os = "windows",
target_os = "linux",
target_os = "macos"
)))]
#[cfg(any(
feature = "force_webpki_roots",
not(any(
target_os = "windows",
target_os = "linux",
target_os = "macos",
)),
))]
{
roots.add_server_trust_anchors(
webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|a| {
rustls::OwnedTrustAnchor::from_subject_spki_name_constraints(
a.subject.to_vec(),
a.spki.to_vec(),
a.name_constraints.map(|c| c.to_vec()),
)
}),
);
roots.roots = webpki_roots::TLS_SERVER_ROOTS.iter().cloned().collect();
}

#[cfg(any(
target_os = "windows",
target_os = "linux",
target_os = "macos"
#[cfg(all(
not(feature = "force_webpki_roots"),
any(target_os = "windows", target_os = "linux", target_os = "macos",),
))]
for cert in rustls_native_certs::load_native_certs()
.expect("failed to load system tls certs")
Expand Down
2 changes: 1 addition & 1 deletion rust/sbd-e2e-crypto-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ documentation = "https://docs.rs/sbd-e2e-crypto-client"
authors = ["Holochain Core Dev Team <[email protected]>"]
keywords = ["holochain", "holo", "p2p", "networking"]
categories = ["network-programming"]
version = "0.0.2-alpha"
version = "0.0.3-alpha"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion rust/sbd-o-bahn-client-tester/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sbd-o-bahn-client-tester"
version = "0.0.2-alpha"
version = "0.0.3-alpha"
description = "simple websocket-based message relay client tester"
license = "MIT OR Apache-2.0"
repository = "https://github.com/holochain/sbd"
Expand Down
2 changes: 1 addition & 1 deletion rust/sbd-o-bahn-server-tester/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sbd-o-bahn-server-tester"
version = "0.0.2-alpha"
version = "0.0.3-alpha"
description = "simple websocket-based message relay server tester"
license = "MIT OR Apache-2.0"
repository = "https://github.com/holochain/sbd"
Expand Down
2 changes: 1 addition & 1 deletion rust/sbd-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sbd-server"
version = "0.0.2-alpha"
version = "0.0.3-alpha"
description = "simple websocket-based message relay server"
license = "MIT OR Apache-2.0"
repository = "https://github.com/holochain/sbd"
Expand Down

0 comments on commit 8f76229

Please sign in to comment.