Skip to content

Commit

Permalink
Fixing Ability to runs https requests
Browse files Browse the repository at this point in the history
  • Loading branch information
amigin committed Apr 5, 2024
1 parent 2d9b3f6 commit 2057507
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions my-grpc-extensions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ my-logger = { tag = "1.1.0", git = "https://github.com/MyJetTools/my-logger.git"
rust-extensions = { tag = "0.1.4", git = "https://github.com/MyJetTools/rust-extensions.git", features = [
"with-tokio",
] }

my-tls = { tag = "0.1.1", git = "https://github.com/MyJetTools/my-tls.git" }
tokio = { version = "*", features = ["full"] }
tonic = { version = "0", features = ["tls", "tls-roots", "prost"] }
hyper = { version = "0" }
Expand Down
10 changes: 8 additions & 2 deletions my-grpc-extensions/src/grpc_channel/grpc_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use my_logger::LogEventCtx;
use my_telemetry::MyTelemetryContext;

use tokio::{sync::Mutex, time::error::Elapsed};
use tonic::transport::Channel;
use tonic::transport::{Certificate, Channel, ClientTlsConfig};

use crate::{GrpcChannelPool, RentedChannel};

Expand Down Expand Up @@ -100,7 +100,13 @@ impl<'s, TService: Send + Sync + 'static> GrpcChannel<TService> {
)
}

let end_point = end_point.unwrap();
let mut end_point = end_point.unwrap();

if connect_url.to_lowercase().starts_with("https") {
let cert = Certificate::from_pem(my_tls::ALL_CERTIFICATES);
let tls = ClientTlsConfig::new().ca_certificate(cert);
end_point = end_point.tls_config(tls).unwrap();
}

match tokio::time::timeout(self.request_timeout, end_point.connect()).await {
Ok(channel) => match channel {
Expand Down

0 comments on commit 2057507

Please sign in to comment.