1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 15:49:44 -05:00

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.
This commit is contained in:
Ben Noordhuis 2021-09-22 11:12:08 +02:00 committed by GitHub
parent f27902e749
commit 82cfb46bd1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 9 deletions

View file

@ -699,9 +699,8 @@ where
let unsafely_ignore_certificate_errors = state
.borrow()
.borrow::<UnsafelyIgnoreCertificateErrors>()
.0
.clone();
.try_borrow::<UnsafelyIgnoreCertificateErrors>()
.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<T> to reduce
@ -768,9 +767,8 @@ where
let cert_file = args.cert_file.as_deref();
let unsafely_ignore_certificate_errors = state
.borrow()
.borrow::<UnsafelyIgnoreCertificateErrors>()
.0
.clone();
.try_borrow::<UnsafelyIgnoreCertificateErrors>()
.and_then(|it| it.0.clone());
if args.cert_chain.is_some() {
super::check_unstable2(&state, "ConnectTlsOptions.certChain");

View file

@ -224,9 +224,8 @@ where
let unsafely_ignore_certificate_errors = state
.borrow()
.borrow::<UnsafelyIgnoreCertificateErrors>()
.0
.clone();
.try_borrow::<UnsafelyIgnoreCertificateErrors>()
.and_then(|it| it.0.clone());
let root_cert_store = state.borrow().borrow::<WsRootStore>().0.clone();
let user_agent = state.borrow().borrow::<WsUserAgent>().0.clone();
let uri: Uri = args.url.parse()?;