diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2021-08-10 13:19:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-10 13:19:45 +0200 |
commit | b9a8111a00b58e355baf60a55893dbfc70b0dfdd (patch) | |
tree | 99f88f95143ddeaa11f77dd80dccacb03f6d5270 /extensions | |
parent | 465cf9a6fe2d77f4c3cdaeb8eea60bd2b8697608 (diff) |
refactor: --unsafely-ignore-certificate-errors (#11629)
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/fetch/lib.rs | 12 | ||||
-rw-r--r-- | extensions/net/lib.rs | 10 | ||||
-rw-r--r-- | extensions/net/ops_tls.rs | 8 | ||||
-rw-r--r-- | extensions/tls/lib.rs | 8 | ||||
-rw-r--r-- | extensions/websocket/lib.rs | 16 |
5 files changed, 27 insertions, 27 deletions
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<P: FetchPermissions + 'static>( root_cert_store: Option<RootCertStore>, proxy: Option<Proxy>, request_builder_hook: Option<fn(RequestBuilder) -> RequestBuilder>, - unsafely_treat_insecure_origin_as_secure: Option<Vec<String>>, + unsafely_ignore_certificate_errors: Option<Vec<String>>, ) -> Extension { Extension::builder() .js(include_js_files!( @@ -88,7 +88,7 @@ pub fn init<P: FetchPermissions + 'static>( 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<P: FetchPermissions + 'static>( 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<RootCertStore>, pub proxy: Option<Proxy>, pub request_builder_hook: Option<fn(RequestBuilder) -> RequestBuilder>, - pub unsafely_treat_insecure_origin_as_secure: Option<Vec<String>>, + pub unsafely_ignore_certificate_errors: Option<Vec<String>>, } 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<RootCertStore>, } -/// `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<Vec<String>>` could work, but there's a high chance /// that there might be another type alias pointing to a `Option<Vec<String>>`, which /// would override previously used alias. -pub struct UnsafelyTreatInsecureOriginAsSecure(Option<Vec<String>>); +pub struct UnsafelyIgnoreCertificateErrors(Option<Vec<String>>); pub fn init<P: NetPermissions + 'static>( root_cert_store: Option<RootCertStore>, unstable: bool, - unsafely_treat_insecure_origin_as_secure: Option<Vec<String>>, + unsafely_ignore_certificate_errors: Option<Vec<String>>, ) -> Extension { let mut ops_to_register = vec![]; ops_to_register.extend(io::init()); @@ -122,8 +122,8 @@ pub fn init<P: NetPermissions + 'static>( 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::<UnsafelyTreatInsecureOriginAsSecure>() + .borrow::<UnsafelyIgnoreCertificateErrors>() .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<RootCertStore>, ca_data: Option<Vec<u8>>, - unsafely_treat_insecure_origin_as_secure: Option<Vec<String>>, + unsafely_ignore_certificate_errors: Option<Vec<String>>, ) -> Result<ClientConfig, AnyError> { 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<RootCertStore>, ca_data: Option<Vec<u8>>, proxy: Option<Proxy>, - unsafely_treat_insecure_origin_as_secure: Option<Vec<String>>, + unsafely_ignore_certificate_errors: Option<Vec<String>>, ) -> Result<Client, AnyError> { 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<Vec<String>>` could work, but there's a high chance /// that there might be another type alias pointing to a `Option<Vec<String>>`, which /// would override previously used alias. -pub struct UnsafelyTreatInsecureOriginAsSecure(Option<Vec<String>>); +pub struct UnsafelyIgnoreCertificateErrors(Option<Vec<String>>); /// 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::<UnsafelyTreatInsecureOriginAsSecure>() + .borrow::<UnsafelyIgnoreCertificateErrors>() .0 .clone(); let root_cert_store = state.borrow().borrow::<WsRootStore>().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<P: WebSocketPermissions + 'static>( user_agent: String, root_cert_store: Option<RootCertStore>, - unsafely_treat_insecure_origin_as_secure: Option<Vec<String>>, + unsafely_ignore_certificate_errors: Option<Vec<String>>, ) -> Extension { Extension::builder() .js(include_js_files!( @@ -450,8 +450,8 @@ pub fn init<P: WebSocketPermissions + 'static>( ]) .state(move |state| { state.put::<WsUserAgent>(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>(WsRootStore(root_cert_store.clone())); Ok(()) |