mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-03-30 10:19:51 +08:00
43 lines
1.8 KiB
C#
43 lines
1.8 KiB
C#
using System.Security.Cryptography.X509Certificates;
|
|
|
|
namespace MicaSetup.Helper;
|
|
|
|
public static class CertificateHelper
|
|
{
|
|
public static void Install(byte[] cer, string password = null!, StoreName storeName = StoreName.Root, StoreLocation storeLocation = StoreLocation.LocalMachine)
|
|
{
|
|
using X509Certificate2 cert = password == null ? new(cer) : new(cer, password);
|
|
using X509Store store = new(storeName, storeLocation);
|
|
store.Open(OpenFlags.ReadWrite);
|
|
store.Add(cert);
|
|
store.Close();
|
|
}
|
|
|
|
public static void Install(string cerFilePath, string password = null!, StoreName storeName = StoreName.Root, StoreLocation storeLocation = StoreLocation.LocalMachine)
|
|
{
|
|
using X509Certificate2 cert = password == null ? new(cerFilePath) : new(cerFilePath, password);
|
|
using X509Store store = new(storeName, storeLocation);
|
|
store.Open(OpenFlags.ReadWrite);
|
|
store.Add(cert);
|
|
store.Close();
|
|
}
|
|
|
|
public static void Uninstall(byte[] cer, string password = null!, StoreName storeName = StoreName.Root, StoreLocation storeLocation = StoreLocation.LocalMachine)
|
|
{
|
|
using X509Certificate2 cert = password == null ? new(cer) : new(cer, password);
|
|
using X509Store store = new(storeName, storeLocation);
|
|
store.Open(OpenFlags.ReadWrite);
|
|
store.Remove(cert);
|
|
store.Close();
|
|
}
|
|
|
|
public static void Uninstall(string cerFilePath, string password = null!, StoreName storeName = StoreName.Root, StoreLocation storeLocation = StoreLocation.LocalMachine)
|
|
{
|
|
using X509Certificate2 cert = password == null ? new(cerFilePath) : new(cerFilePath, password);
|
|
using X509Store store = new(storeName, storeLocation);
|
|
store.Open(OpenFlags.ReadWrite);
|
|
store.Remove(cert);
|
|
store.Close();
|
|
}
|
|
}
|