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:
@@ -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?;
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user