Save cert to disk
This commit is contained in:
parent
3129170217
commit
1d211d5f15
@ -100,7 +100,8 @@ internal class Program
|
||||
var paths = $"Paths: {nameof(PathHelper.HtmlRootPath)}: {PathHelper.HtmlRootPath}\n" +
|
||||
$"{nameof(PathHelper.LogRootPath)}: {PathHelper.LogRootPath}\n" +
|
||||
$"{nameof(PathHelper.DataBaseRootPath)}: {PathHelper.DataBaseRootPath}\n" +
|
||||
$"{nameof(PathHelper.ConfigFilePath)}: {PathHelper.ConfigFilePath}\n";
|
||||
$"{nameof(PathHelper.ConfigFilePath)}: {PathHelper.ConfigFilePath}\n" +
|
||||
$"{nameof(PathHelper.CertRootPath)}: {PathHelper.CertRootPath}\n";
|
||||
paths.Info();
|
||||
|
||||
}
|
||||
|
@ -129,10 +129,16 @@ public static class CertificateHelper
|
||||
var certWithPrivateKey = new X509Certificate2(certPfxBytes, (string)null!,
|
||||
X509_KEY_STORAGE_FLAGS_MACHINE);
|
||||
|
||||
|
||||
AddCertToStore(rootCaWithPrivateKey, StoreName.My, StoreLocation.LocalMachine);
|
||||
AddCertToStore(rootCaWithPrivateKey, StoreName.Root, StoreLocation.LocalMachine);
|
||||
AddCertToStore(certWithPrivateKey, StoreName.My, StoreLocation.LocalMachine);
|
||||
|
||||
Directory.CreateDirectory(PathHelper.CertRootPath);
|
||||
|
||||
File.WriteAllBytes(Path.Combine(PathHelper.CertRootPath, "root.pfx"), rootCaWithPrivateKey.Export(X509ContentType.Pfx));
|
||||
File.WriteAllBytes(Path.Combine(PathHelper.CertRootPath, "cert.pfx"), certWithPrivateKey.Export(X509ContentType.Pfx));
|
||||
|
||||
return certWithPrivateKey;
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,8 @@ public static class Configs
|
||||
|
||||
public const string LOG_FOLDER = "log";
|
||||
|
||||
public const string CERT_FOLDER = "certs";
|
||||
|
||||
public const string LOG_BASE_NAME = "log";
|
||||
|
||||
public const string STATIC_FOLDER = "static";
|
||||
|
@ -17,6 +17,8 @@ public static class PathHelper
|
||||
|
||||
public static string LogRootPath => Path.Combine(BasePath, Configs.LOG_FOLDER);
|
||||
|
||||
public static string CertRootPath => Path.Combine(BasePath, Configs.CERT_FOLDER);
|
||||
|
||||
public static string ConfigFilePath => Environment.ProcessPath ?? string.Empty;
|
||||
|
||||
private static string BasePath
|
||||
|
Loading…
Reference in New Issue
Block a user