Skip to content

Commit

Permalink
fix: fix https connections without explicitly passed certificates (#119)
Browse files Browse the repository at this point in the history
* fix

* attempt 2

* add comment

* cleanup

* make it more concise
  • Loading branch information
t-aleksander committed Aug 30, 2024
1 parent f436b30 commit 08919d2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ prost = "0.13"
serde = { version = "1.0", features = ["derive"] }
syslog = "7.0"
thiserror = "1.0"
tonic = { version = "0.12", features = ["gzip", "tls", "tls-roots"] }
tonic = { version = "0.12", features = ["gzip", "tls", "tls-native-roots"] }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
tokio-stream = { version = "0.1", features = [] }
toml = { version = "0.8", default-features = false, features = ["parse"] }
Expand Down
4 changes: 3 additions & 1 deletion src/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,14 @@ impl Gateway {
.http2_keep_alive_interval(TEN_SECS)
.tcp_keepalive(Some(TEN_SECS))
.keep_alive_while_idle(true);
// if CA certificate is provided, use it (and only it)
// otherwise load certs from system
let endpoint = if let Some(ca) = &self.config.grpc_ca {
let ca = std::fs::read_to_string(ca)?;
let tls = ClientTlsConfig::new().ca_certificate(Certificate::from_pem(ca));
endpoint.tls_config(tls)?
} else {
endpoint
endpoint.tls_config(ClientTlsConfig::new().with_native_roots())?
};
let channel = endpoint.connect_lazy();

Expand Down

0 comments on commit 08919d2

Please sign in to comment.