From aa5b5b035a63abc3c0d8fe854cb18c0f55c19726 Mon Sep 17 00:00:00 2001
From: Yuuki <6851027-yukiz@users.noreply.gitlab.com>
Date: Mon, 1 Apr 2024 07:52:27 +0800
Subject: [PATCH] Show forever (loop) continues to `install certificate` until
the user clicks yes
---
Main.cs | 43 ++++++++++++++++++++++++++++++++++++-----
YuukiPS Launcher.csproj | 4 ++--
2 files changed, 40 insertions(+), 7 deletions(-)
diff --git a/Main.cs b/Main.cs
index 6c1ed03..b26ee01 100644
--- a/Main.cs
+++ b/Main.cs
@@ -8,6 +8,7 @@
using ICSharpCode.SharpZipLib.Zip;
using YuukiPS_Launcher.Utils;
using System.Net;
+using System.Security.Cryptography.X509Certificates;
namespace YuukiPS_Launcher
{
@@ -451,8 +452,7 @@ public void DoStart()
{
// skip
}
- proxy.Stop();
- proxy = null;
+ StopProxy();
return;
}
else
@@ -461,8 +461,8 @@ public void DoStart()
{
if (!API.isYuuki(set_proxy_port))
{
- proxy.Stop();
- proxy = null;
+ StopProxy();
+ InstallCert();
MessageBox.Show("Try closing this program then opening it again, if there is still an error, please report it to admin with a screenshot console", "Not yet connected to YuukiPS server");
return;
}
@@ -533,6 +533,36 @@ public void DoStart()
}
}
+ public void InstallCert()
+ {
+ bool installationSucceeded = false;
+ while (!installationSucceeded)
+ {
+ try
+ {
+ // Load the certificate from the file
+ X509Certificate2 certificate = new X509Certificate2("rootCert.pfx");
+
+ // Open the Root certificate store for the current user
+ X509Store store = new X509Store(StoreName.Root, StoreLocation.CurrentUser);
+ store.Open(OpenFlags.ReadWrite);
+
+ // Add the certificate to the store
+ store.Add(certificate);
+
+ // Close the store
+ store.Close();
+
+ Console.WriteLine("Certificate installed successfully.");
+ installationSucceeded = true; // Set flag to true to exit the loop
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("Error: " + ex.Message);
+ }
+ }
+ }
+
public bool CheckVersionGame(GameType game_type)
{
var cst_folder_game = Set_LA_GameFolder.Text;
@@ -1722,12 +1752,15 @@ public void AllStop()
public void StopProxy()
{
- if (proxy != null)
+ try
{
proxy.Stop();
proxy = null;
Logger.Info("Proxy", "Proxy Stop....");
}
+ catch (Exception ex) {
+ // skip
+ }
}
public void StopGame()
diff --git a/YuukiPS Launcher.csproj b/YuukiPS Launcher.csproj
index 6b42d59..99eb799 100644
--- a/YuukiPS Launcher.csproj
+++ b/YuukiPS Launcher.csproj
@@ -12,8 +12,8 @@
Properties\app.manifest
- 2024.3.31.2132
- 2024.3.31.2132
+ 2024.3.31.2350
+ 2024.3.31.2350
true
YuukiPS