diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index 8a3ab99..283a7b4 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -2,6 +2,7 @@
+
\ No newline at end of file
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index dfebeae..7995859 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -97,7 +97,7 @@ fn enable_process_watcher(process: String) {
}
#[tauri::command]
-async fn connect(port: u16) {
+async fn connect(port: u16, certificate_path: String) {
// Log message to console.
println!("Connecting to proxy...");
@@ -105,7 +105,7 @@ async fn connect(port: u16) {
proxy::connect_to_proxy(port);
// Create and start a proxy.
- proxy::create_proxy(port).await;
+ proxy::create_proxy(port, certificate_path).await;
}
#[tauri::command]
diff --git a/src-tauri/src/proxy.rs b/src-tauri/src/proxy.rs
index 644703a..4c776a0 100644
--- a/src-tauri/src/proxy.rs
+++ b/src-tauri/src/proxy.rs
@@ -73,10 +73,10 @@ impl HttpHandler for ProxyHandler {
/**
* Starts an HTTP(S) proxy server.
*/
-pub(crate) async fn create_proxy(proxy_port: u16) {
+pub async fn create_proxy(proxy_port: u16, certificate_path: String) {
// Get the certificate and private key.
- let mut private_key_bytes: &[u8] = include_bytes!("../resources/private-key.pem");
- let mut ca_cert_bytes: &[u8] = include_bytes!("../resources/ca-certificate.pem");
+ let mut private_key_bytes: &[u8] = include_bytes!(format!("{}/private.key", certificate_path));
+ let mut ca_cert_bytes: &[u8] = include_bytes!(format!("{}/cert.crt", certificate_path));
// Parse the private key and certificate.
let private_key = rustls::PrivateKey(
@@ -110,7 +110,7 @@ pub(crate) async fn create_proxy(proxy_port: u16) {
/**
* Connects to the local HTTP(S) proxy server.
*/
-pub(crate) fn connect_to_proxy(proxy_port: u16) {
+pub fn connect_to_proxy(proxy_port: u16) {
if cfg!(target_os = "windows") {
// Create 'ProxyServer' string.
let server_string: String = format!("http=127.0.0.1:{};https=127.0.0.1:{}", proxy_port, proxy_port);
@@ -129,7 +129,7 @@ pub(crate) fn connect_to_proxy(proxy_port: u16) {
/**
* Disconnects from the local HTTP(S) proxy server.
*/
-pub(crate) fn disconnect_from_proxy() {
+pub fn disconnect_from_proxy() {
if cfg!(target_os = "windows") {
// Fetch the 'Internet Settings' registry key.
let settings = Hive::CurrentUser.open(r"Software\Microsoft\Windows\CurrentVersion\Internet Settings", Security::Write).unwrap();
@@ -147,7 +147,7 @@ pub(crate) fn disconnect_from_proxy() {
* Source: https://github.com/zu1k/good-mitm/raw/master/src/ca/gen.rs
*/
#[tauri::command]
-pub(crate) fn generate_ca_files(path: &str) {
+pub fn generate_ca_files(path: &str) {
let mut params = CertificateParams::default();
let mut details = DistinguishedName::new();
@@ -201,7 +201,7 @@ pub(crate) fn generate_ca_files(path: &str) {
/*
* Attempts to install the certificate authority's certificate into the Root CA store.
*/
-pub(crate) fn install_ca_files(path: &str) {
+pub fn install_ca_files(path: &str) {
if cfg!(target_os = "windows") {
run_command(format!("certutil -addstore -f \"ROOT\" {}\\ca\\certificate.crt", path).to_string());
} else {
diff --git a/src/index.tsx b/src/index.tsx
index 9d175a4..27dbf9c 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -12,6 +12,7 @@ const root = ReactDOM.createRoot(
root.render(
+ {/**/}
)
@@ -19,4 +20,4 @@ root.render(
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
import reportWebVitals from './utils/reportWebVitals'
-reportWebVitals()
+reportWebVitals()
\ No newline at end of file
diff --git a/src/ui/Test.tsx b/src/ui/Test.tsx
index b4a60ba..77f2d1b 100644
--- a/src/ui/Test.tsx
+++ b/src/ui/Test.tsx
@@ -1,9 +1,10 @@
import React from 'react'
import {invoke} from '@tauri-apps/api/tauri'
+import {dataDir} from '@tauri-apps/api/path'
async function startProxy() {
- await invoke('connect', { port: 2222 })
+ await invoke('connect', { port: 2222, certificate_path: await dataDir() + '\\ca' })
}
async function stopProxy() {
diff --git a/src/ui/components/ServerLaunchSection.tsx b/src/ui/components/ServerLaunchSection.tsx
index af392db..a614cc1 100644
--- a/src/ui/components/ServerLaunchSection.tsx
+++ b/src/ui/components/ServerLaunchSection.tsx
@@ -9,6 +9,7 @@ import { invoke } from '@tauri-apps/api/tauri'
import Server from '../../resources/icons/server.svg'
import './ServerLaunchSection.css'
+import {dataDir} from '@tauri-apps/api/path'
interface IProps {
[key: string]: any
@@ -105,7 +106,7 @@ export default class ServerLaunchSection extends React.Component
})
// Connect to proxy
- await invoke('connect', { port: 8365 })
+ await invoke('connect', { port: 8365, certificate_path: await dataDir() + '\\ca' })
}
// Launch the program