diff --git a/Quasar.Server/Build/ClientBuilder.cs b/Quasar.Server/Build/ClientBuilder.cs index 4f05b123..625443ee 100644 --- a/Quasar.Server/Build/ClientBuilder.cs +++ b/Quasar.Server/Build/ClientBuilder.cs @@ -85,7 +85,7 @@ private void WriteSettings(AssemblyDefinition asmDef) var key = StringHelper.GetRandomString(32); var aes = new Aes256(key); - var caCertificate = new X509Certificate2(Path.Combine(Application.StartupPath, "quasar.p12"), "", X509KeyStorageFlags.Exportable); + var caCertificate = new X509Certificate2(Settings.CertificatePath, "", X509KeyStorageFlags.Exportable); var clientCertificate = CertificateHelper.CreateCertificate("Quasar Client", caCertificate, 4096); var serverCertificate = new X509Certificate2(caCertificate.Export(X509ContentType.Cert)); // export without private key, very important! diff --git a/Quasar.Server/Forms/FrmCertificate.cs b/Quasar.Server/Forms/FrmCertificate.cs index 50bd897a..804aaba7 100644 --- a/Quasar.Server/Forms/FrmCertificate.cs +++ b/Quasar.Server/Forms/FrmCertificate.cs @@ -4,6 +4,7 @@ using System.IO; using System.Security.Cryptography.X509Certificates; using System.Windows.Forms; +using Quasar.Server.Models; namespace Quasar.Server.Forms { @@ -56,14 +57,13 @@ private void btnSave_Click(object sender, EventArgs e) if (!_certificate.HasPrivateKey) throw new ArgumentException(); - string path = Path.Combine(Application.StartupPath, "quasar.p12"); - File.WriteAllBytes(path, _certificate.Export(X509ContentType.Pkcs12)); + File.WriteAllBytes(Settings.CertificatePath, _certificate.Export(X509ContentType.Pkcs12)); MessageBox.Show(this, "Please backup the certificate now. Loss of the certificate results in loosing all clients!", "Certificate backup", MessageBoxButtons.OK, MessageBoxIcon.Information); - string argument = "/select, \"" + path + "\""; + string argument = "/select, \"" + Settings.CertificatePath + "\""; Process.Start("explorer.exe", argument); this.DialogResult = DialogResult.OK; diff --git a/Quasar.Server/Forms/FrmMain.cs b/Quasar.Server/Forms/FrmMain.cs index 1274de57..0a54e596 100644 --- a/Quasar.Server/Forms/FrmMain.cs +++ b/Quasar.Server/Forms/FrmMain.cs @@ -86,8 +86,7 @@ private void InitializeServer() #if DEBUG serverCertificate = CertificateHelper.CreateCertificateAuthority("Quasar Server CA", 2048); #else - string certificatePath = Path.Combine(Application.StartupPath, "quasar.p12"); - if (!File.Exists(certificatePath)) + if (!File.Exists(Settings.CertificatePath)) { using (var certificateSelection = new FrmCertificate()) { @@ -95,7 +94,7 @@ private void InitializeServer() { } } } - serverCertificate = new X509Certificate2(certificatePath); + serverCertificate = new X509Certificate2(Settings.CertificatePath); #endif ListenServer = new QuasarServer(serverCertificate); ListenServer.ServerState += ServerState; diff --git a/Quasar.Server/Models/Settings.cs b/Quasar.Server/Models/Settings.cs index e354f141..b68409cc 100644 --- a/Quasar.Server/Models/Settings.cs +++ b/Quasar.Server/Models/Settings.cs @@ -9,6 +9,8 @@ public static class Settings { private static readonly string SettingsPath = Path.Combine(Application.StartupPath, "settings.xml"); + public static readonly string CertificatePath = Path.Combine(Application.StartupPath, "quasar.p12"); + public static ushort ListenPort { get