Skip to content

Commit

Permalink
Show forever (loop) continues to install certificate until the user…
Browse files Browse the repository at this point in the history
… clicks yes
  • Loading branch information
Yuuki committed Mar 31, 2024
1 parent 4534da4 commit aa5b5b0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
43 changes: 38 additions & 5 deletions Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using ICSharpCode.SharpZipLib.Zip;
using YuukiPS_Launcher.Utils;
using System.Net;
using System.Security.Cryptography.X509Certificates;

namespace YuukiPS_Launcher
{
Expand Down Expand Up @@ -451,8 +452,7 @@ public void DoStart()
{
// skip
}
proxy.Stop();
proxy = null;
StopProxy();
return;
}
else
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions YuukiPS Launcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

<ApplicationManifest>Properties\app.manifest</ApplicationManifest>

<AssemblyVersion>2024.3.31.2132</AssemblyVersion>
<FileVersion>2024.3.31.2132</FileVersion>
<AssemblyVersion>2024.3.31.2350</AssemblyVersion>
<FileVersion>2024.3.31.2350</FileVersion>

<EnableWindowsTargeting>true</EnableWindowsTargeting>
<AssemblyName>YuukiPS</AssemblyName>
Expand Down

0 comments on commit aa5b5b0

Please sign in to comment.