Skip to content

Commit

Permalink
feat: re-enable TLS checks for Android and dev proxy (#10386)
Browse files Browse the repository at this point in the history
* feat: re-enable TLS checks for Android and dev proxy

* update time
  • Loading branch information
lucasfernog authored Jul 29, 2024
1 parent 7aeac39 commit 289ae55
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 37 deletions.
8 changes: 8 additions & 0 deletions .changes/remove-unsecure-configs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"tauri-cli": patch:sec
"@tauri-apps/cli": patch:sec
"tauri": patch:sec
---

Re-enable TLS checks that were previously disabled to support an insecure HTTPS custom protocol on Android which is no longer used.

9 changes: 2 additions & 7 deletions core/tauri/src/protocol/tauri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,8 @@ fn get_response<R: Runtime>(
.decode_utf8_lossy()
.to_string();
let url = format!("{url}{decoded_path}");
#[allow(unused_mut)]
let mut client_builder = reqwest::ClientBuilder::new();
#[cfg(any(feature = "native-tls", feature = "rustls-tls"))]
{
client_builder = client_builder.danger_accept_invalid_certs(true);
}
let mut proxy_builder = client_builder

let mut proxy_builder = reqwest::ClientBuilder::new()
.build()
.unwrap()
.request(request.method().clone(), &url);
Expand Down
16 changes: 8 additions & 8 deletions examples/api/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/api/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export default defineConfig({
hmr: mobile
? {
protocol: 'ws',
host: internalIpV4Sync(),
port: 1421
host: mobile ? internalIpV4Sync() : 'localhost',
port: 1430
}
: undefined,
fs: {
Expand Down
5 changes: 1 addition & 4 deletions tooling/cli/src/mobile/android/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use cargo_mobile2::{
target::TargetTrait,
};

use std::env::{set_current_dir, set_var};
use std::env::set_current_dir;

#[derive(Debug, Clone, Parser)]
#[clap(
Expand Down Expand Up @@ -122,9 +122,6 @@ pub fn command(options: Options, noise_level: NoiseLevel) -> Result<()> {
(interface, app, config, metadata)
};

set_var("WRY_RUSTWEBVIEWCLIENT_CLASS_EXTENSION", "");
set_var("WRY_RUSTWEBVIEW_CLASS_INIT", "");

let profile = if options.debug {
Profile::Debug
} else {
Expand Down
17 changes: 1 addition & 16 deletions tooling/cli/src/mobile/android/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,7 @@ use cargo_mobile2::{
target::TargetTrait,
};

use std::env::{set_current_dir, set_var};

const WEBVIEW_CLIENT_CLASS_EXTENSION: &str = "
@android.annotation.SuppressLint(\"WebViewClientOnReceivedSslError\")
override fun onReceivedSslError(view: WebView?, handler: SslErrorHandler, error: android.net.http.SslError) {
handler.proceed()
}
";
const WEBVIEW_CLASS_INIT: &str =
"this.settings.mixedContentMode = android.webkit.WebSettings.MIXED_CONTENT_ALWAYS_ALLOW";
use std::env::set_current_dir;

#[derive(Debug, Clone, Parser)]
#[clap(
Expand Down Expand Up @@ -154,12 +145,6 @@ fn run_command(options: Options, noise_level: NoiseLevel) -> Result<()> {
(interface, app, config, metadata)
};

set_var(
"WRY_RUSTWEBVIEWCLIENT_CLASS_EXTENSION",
WEBVIEW_CLIENT_CLASS_EXTENSION,
);
set_var("WRY_RUSTWEBVIEW_CLASS_INIT", WEBVIEW_CLASS_INIT);

let tauri_path = tauri_dir();
set_current_dir(tauri_path).with_context(|| "failed to change current working directory")?;

Expand Down

0 comments on commit 289ae55

Please sign in to comment.