fix(transport): Propagate errors in tls_config instead of unwrap/panic (#385)

* Propagate errors in tls_config instead of unwrap

Ran into `tls_connector` failing and causing our app to panic and shutdown as it seems there wasn't any way to avoid panicking in `tls_config`.

So after talking to @LucioFranco briefly `tls_config` now returns a `Result` instead and propagates errors to the caller, where they can be handled.

* Fix compile warning when tls feature is disabled
This commit is contained in:
Johan Andersson
2020-07-06 09:18:10 -04:00
committed by GitHub
parent f085aba302
commit 3b9d6a6262
10 changed files with 28 additions and 17 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
ClientTlsConfig::new()
.ca_certificate(ca)
.domain_name("foo.test.google.fr"),
);
)?;
}
let channel = endpoint.connect().await?;
+1 -1
View File
@@ -24,7 +24,7 @@ async fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
let key = tokio::fs::read("interop/data/server1.key").await?;
let identity = Identity::from_pem(cert, key);
builder = builder.tls_config(ServerTlsConfig::new().identity(identity));
builder = builder.tls_config(ServerTlsConfig::new().identity(identity))?;
}
let test_service = server::TestServiceServer::new(server::TestService::default());