From 82cfb46bd1d64d41afda544bde9ef57096fb520b Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 22 Sep 2021 11:12:08 +0200 Subject: chore(ext/net): improve embedder friendliness (#12178) Default to None if UnsafelyIgnoreCertificateErrors is not present in the OpState. Embedders may not have a need for restricting outgoing TLS connections and having them hunt through the source code for the magic incantation that makes the borrow panics go away, is less user friendly. --- ext/net/ops_tls.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'ext/net') diff --git a/ext/net/ops_tls.rs b/ext/net/ops_tls.rs index 89879da68..17367af54 100644 --- a/ext/net/ops_tls.rs +++ b/ext/net/ops_tls.rs @@ -699,9 +699,8 @@ where let unsafely_ignore_certificate_errors = state .borrow() - .borrow::() - .0 - .clone(); + .try_borrow::() + .and_then(|it| it.0.clone()); // TODO(@justinmchase): Ideally the certificate store is created once // and not cloned. The store should be wrapped in Arc to reduce @@ -768,9 +767,8 @@ where let cert_file = args.cert_file.as_deref(); let unsafely_ignore_certificate_errors = state .borrow() - .borrow::() - .0 - .clone(); + .try_borrow::() + .and_then(|it| it.0.clone()); if args.cert_chain.is_some() { super::check_unstable2(&state, "ConnectTlsOptions.certChain"); -- cgit v1.2.3