From b9a8111a00b58e355baf60a55893dbfc70b0dfdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 10 Aug 2021 13:19:45 +0200 Subject: refactor: --unsafely-ignore-certificate-errors (#11629) --- extensions/fetch/lib.rs | 12 ++++++------ extensions/net/lib.rs | 10 +++++----- extensions/net/ops_tls.rs | 8 ++++---- extensions/tls/lib.rs | 8 ++++---- extensions/websocket/lib.rs | 16 ++++++++-------- 5 files changed, 27 insertions(+), 27 deletions(-) (limited to 'extensions') diff --git a/extensions/fetch/lib.rs b/extensions/fetch/lib.rs index cc5954b74..d9e016b0d 100644 --- a/extensions/fetch/lib.rs +++ b/extensions/fetch/lib.rs @@ -60,7 +60,7 @@ pub fn init( root_cert_store: Option, proxy: Option, request_builder_hook: Option RequestBuilder>, - unsafely_treat_insecure_origin_as_secure: Option>, + unsafely_ignore_certificate_errors: Option>, ) -> Extension { Extension::builder() .js(include_js_files!( @@ -88,7 +88,7 @@ pub fn init( root_cert_store.clone(), None, proxy.clone(), - unsafely_treat_insecure_origin_as_secure.clone(), + unsafely_ignore_certificate_errors.clone(), ) .unwrap() }); @@ -97,8 +97,8 @@ pub fn init( root_cert_store: root_cert_store.clone(), proxy: proxy.clone(), request_builder_hook, - unsafely_treat_insecure_origin_as_secure: - unsafely_treat_insecure_origin_as_secure.clone(), + unsafely_ignore_certificate_errors: unsafely_ignore_certificate_errors + .clone(), }); Ok(()) }) @@ -110,7 +110,7 @@ pub struct HttpClientDefaults { pub root_cert_store: Option, pub proxy: Option, pub request_builder_hook: Option RequestBuilder>, - pub unsafely_treat_insecure_origin_as_secure: Option>, + pub unsafely_ignore_certificate_errors: Option>, } pub trait FetchPermissions { @@ -543,7 +543,7 @@ where defaults.root_cert_store.clone(), cert_data, args.proxy, - defaults.unsafely_treat_insecure_origin_as_secure.clone(), + defaults.unsafely_ignore_certificate_errors.clone(), ) .unwrap(); diff --git a/extensions/net/lib.rs b/extensions/net/lib.rs index f68034517..fe10abf5f 100644 --- a/extensions/net/lib.rs +++ b/extensions/net/lib.rs @@ -94,16 +94,16 @@ pub struct DefaultTlsOptions { pub root_cert_store: Option, } -/// `UnsafelyTreatInsecureOriginAsSecure` is a wrapper struct so it can be placed inside `GothamState`; +/// `UnsafelyIgnoreCertificateErrors` is a wrapper struct so it can be placed inside `GothamState`; /// using type alias for a `Option>` could work, but there's a high chance /// that there might be another type alias pointing to a `Option>`, which /// would override previously used alias. -pub struct UnsafelyTreatInsecureOriginAsSecure(Option>); +pub struct UnsafelyIgnoreCertificateErrors(Option>); pub fn init( root_cert_store: Option, unstable: bool, - unsafely_treat_insecure_origin_as_secure: Option>, + unsafely_ignore_certificate_errors: Option>, ) -> Extension { let mut ops_to_register = vec![]; ops_to_register.extend(io::init()); @@ -122,8 +122,8 @@ pub fn init( root_cert_store: root_cert_store.clone(), }); state.put(UnstableChecker { unstable }); - state.put(UnsafelyTreatInsecureOriginAsSecure( - unsafely_treat_insecure_origin_as_secure.clone(), + state.put(UnsafelyIgnoreCertificateErrors( + unsafely_ignore_certificate_errors.clone(), )); Ok(()) }) diff --git a/extensions/net/ops_tls.rs b/extensions/net/ops_tls.rs index 6c26ed748..91fad6706 100644 --- a/extensions/net/ops_tls.rs +++ b/extensions/net/ops_tls.rs @@ -9,7 +9,7 @@ use crate::resolve_addr::resolve_addr; use crate::resolve_addr::resolve_addr_sync; use crate::DefaultTlsOptions; use crate::NetPermissions; -use crate::UnsafelyTreatInsecureOriginAsSecure; +use crate::UnsafelyIgnoreCertificateErrors; use deno_core::error::bad_resource; use deno_core::error::bad_resource_id; use deno_core::error::custom_error; @@ -761,9 +761,9 @@ where }; let port = args.port; let cert_file = args.cert_file.as_deref(); - let unsafely_treat_insecure_origin_as_secure = state + let unsafely_ignore_certificate_errors = state .borrow() - .borrow::() + .borrow::() .0 .clone(); @@ -810,7 +810,7 @@ where let mut tls_config = create_client_config( root_cert_store, ca_data, - unsafely_treat_insecure_origin_as_secure, + unsafely_ignore_certificate_errors, )?; if args.cert_chain.is_some() || args.private_key.is_some() { diff --git a/extensions/tls/lib.rs b/extensions/tls/lib.rs index 2a15b4e75..932f5ba4c 100644 --- a/extensions/tls/lib.rs +++ b/extensions/tls/lib.rs @@ -125,7 +125,7 @@ pub fn create_default_root_cert_store() -> RootCertStore { pub fn create_client_config( root_cert_store: Option, ca_data: Option>, - unsafely_treat_insecure_origin_as_secure: Option>, + unsafely_ignore_certificate_errors: Option>, ) -> Result { let mut tls_config = ClientConfig::new(); tls_config.set_persistence(CLIENT_SESSION_MEMORY_CACHE.clone()); @@ -141,7 +141,7 @@ pub fn create_client_config( } } - if let Some(ic_allowlist) = unsafely_treat_insecure_origin_as_secure { + if let Some(ic_allowlist) = unsafely_ignore_certificate_errors { tls_config.dangerous().set_certificate_verifier(Arc::new( NoCertificateVerification(ic_allowlist), )); @@ -157,12 +157,12 @@ pub fn create_http_client( root_cert_store: Option, ca_data: Option>, proxy: Option, - unsafely_treat_insecure_origin_as_secure: Option>, + unsafely_ignore_certificate_errors: Option>, ) -> Result { let tls_config = create_client_config( root_cert_store, ca_data, - unsafely_treat_insecure_origin_as_secure, + unsafely_ignore_certificate_errors, )?; let mut headers = HeaderMap::new(); headers.insert(USER_AGENT, user_agent.parse().unwrap()); diff --git a/extensions/websocket/lib.rs b/extensions/websocket/lib.rs index 97e970e85..69c6154b8 100644 --- a/extensions/websocket/lib.rs +++ b/extensions/websocket/lib.rs @@ -54,11 +54,11 @@ pub trait WebSocketPermissions { fn check_net_url(&mut self, _url: &url::Url) -> Result<(), AnyError>; } -/// `UnsafelyTreatInsecureOriginAsSecure` is a wrapper struct so it can be placed inside `GothamState`; +/// `UnsafelyIgnoreCertificateErrors` is a wrapper struct so it can be placed inside `GothamState`; /// using type alias for a `Option>` could work, but there's a high chance /// that there might be another type alias pointing to a `Option>`, which /// would override previously used alias. -pub struct UnsafelyTreatInsecureOriginAsSecure(Option>); +pub struct UnsafelyIgnoreCertificateErrors(Option>); /// For use with `op_websocket_*` when the user does not want permissions. pub struct NoWebSocketPermissions; @@ -223,9 +223,9 @@ where ); } - let unsafely_treat_insecure_origin_as_secure = state + let unsafely_ignore_certificate_errors = state .borrow() - .borrow::() + .borrow::() .0 .clone(); let root_cert_store = state.borrow().borrow::().0.clone(); @@ -255,7 +255,7 @@ where let tls_config = create_client_config( root_cert_store, None, - unsafely_treat_insecure_origin_as_secure, + unsafely_ignore_certificate_errors, )?; let tls_connector = TlsConnector::from(Arc::new(tls_config)); let dnsname = DNSNameRef::try_from_ascii_str(domain) @@ -430,7 +430,7 @@ pub async fn op_ws_next_event( pub fn init( user_agent: String, root_cert_store: Option, - unsafely_treat_insecure_origin_as_secure: Option>, + unsafely_ignore_certificate_errors: Option>, ) -> Extension { Extension::builder() .js(include_js_files!( @@ -450,8 +450,8 @@ pub fn init( ]) .state(move |state| { state.put::(WsUserAgent(user_agent.clone())); - state.put(UnsafelyTreatInsecureOriginAsSecure( - unsafely_treat_insecure_origin_as_secure.clone(), + state.put(UnsafelyIgnoreCertificateErrors( + unsafely_ignore_certificate_errors.clone(), )); state.put::(WsRootStore(root_cert_store.clone())); Ok(()) -- cgit v1.2.3