1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-25 00:29:09 -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 let unsafely_ignore_certificate_errors = state
.borrow() .borrow()
.borrow::<UnsafelyIgnoreCertificateErrors>() .try_borrow::<UnsafelyIgnoreCertificateErrors>()
.0 .and_then(|it| it.0.clone());
.clone();
// TODO(@justinmchase): Ideally the certificate store is created once // TODO(@justinmchase): Ideally the certificate store is created once
// and not cloned. The store should be wrapped in Arc<T> to reduce // 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 cert_file = args.cert_file.as_deref();
let unsafely_ignore_certificate_errors = state let unsafely_ignore_certificate_errors = state
.borrow() .borrow()
.borrow::<UnsafelyIgnoreCertificateErrors>() .try_borrow::<UnsafelyIgnoreCertificateErrors>()
.0 .and_then(|it| it.0.clone());
.clone();
if args.cert_chain.is_some() { if args.cert_chain.is_some() {
super::check_unstable2(&state, "ConnectTlsOptions.certChain"); super::check_unstable2(&state, "ConnectTlsOptions.certChain");

View file

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