diff --git a/ClientServerLib/ClientServerLib/CServer.cs b/ClientServerLib/ClientServerLib/CServer.cs
index 51a6d2b7..3403a092 100644
--- a/ClientServerLib/ClientServerLib/CServer.cs
+++ b/ClientServerLib/ClientServerLib/CServer.cs
@@ -16,9 +16,9 @@
#endregion
using System;
+using System.Diagnostics;
using System.ServiceModel;
using System.ServiceModel.Web;
-using System.Diagnostics;
using System.Net;
namespace ServerLib
@@ -191,10 +191,15 @@ namespace ServerLib
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden,
};
- Process p = Process.Start(info);
- p.WaitForExit();
- p.Close();
-
+ try
+ {
+ using (Process p = Process.Start(info))
+ {
+ p.WaitForExit();
+ p.Close();
+ }
+ }
+ catch (Exception) {}
#else
//Required?
diff --git a/Output/Security.dll b/Output/Security.dll
deleted file mode 100644
index f0c2c513..00000000
Binary files a/Output/Security.dll and /dev/null differ
diff --git a/WebserverInitalConfig/CConfigHttpApi.cs b/WebserverInitalConfig/CConfigHttpApi.cs
index 38002df3..e16f3a44 100644
--- a/WebserverInitalConfig/CConfigHttpApi.cs
+++ b/WebserverInitalConfig/CConfigHttpApi.cs
@@ -17,6 +17,7 @@
using System.Security.Authentication;
using System.Security.Principal;
+using System.Windows.Forms;
using Security.Cryptography;
using Security.Cryptography.X509Certificates;
using System;
@@ -124,7 +125,22 @@ namespace WebserverInitalConfig
keyParam.Parameters.Add(new CngProperty("Length", BitConverter.GetBytes(2048), CngPropertyOptions.None));
- CngKey key = CngKey.Create(CngAlgorithm2.Rsa, Guid.NewGuid().ToString(), keyParam);
+ CngKey key;
+ try
+ {
+ key= CngKey.Create(CngAlgorithm2.Rsa, Guid.NewGuid().ToString(), keyParam);
+ }
+ catch (PlatformNotSupportedException)
+ {
+ try
+ {
+ key = CngKey.Create(CngAlgorithm2.Aes, Guid.NewGuid().ToString(), keyParam);
+ }
+ catch (PlatformNotSupportedException)
+ {
+ return null;
+ }
+ }
X509CertificateCreationParameters param = new X509CertificateCreationParameters(new X500DistinguishedName(subjectName))
{
@@ -156,6 +172,11 @@ namespace WebserverInitalConfig
if (!IsAdministrator())
throw new AuthenticationException();
cert = _GetSelfSignedCert(certName);
+ if (cert == null)
+ {
+ MessageBox.Show("Could not create certificate. Secure server connection may not work. Disable it if required.");
+ return;
+ }
_AddCertToStore(cert);
}
_BindCert(cert);
diff --git a/WebserverInitalConfig/Program.cs b/WebserverInitalConfig/Program.cs
index fc09dac1..60e3ce4a 100644
--- a/WebserverInitalConfig/Program.cs
+++ b/WebserverInitalConfig/Program.cs
@@ -20,6 +20,7 @@ using System.Diagnostics;
using System.IO;
using System.Net;
using System.Security.Authentication;
+using System.Windows.Forms;
namespace WebserverInitalConfig
{
@@ -29,49 +30,56 @@ namespace WebserverInitalConfig
private static void Main(string[] args)
// ReSharper restore InconsistentNaming
{
- int port;
- if (args.Length < 2 || !int.TryParse(args[0], out port))
+ try
{
- Console.WriteLine("Usage: VocaluxeServerConfig port isHttps");
- Environment.Exit(-1);
- }
- else
- {
- CConfigHttpApi config = new CConfigHttpApi("Vocaluxe", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Vocaluxe.exe"), "0.0.0.0", port, true);
- try
+ int port;
+ if (args.Length < 2 || !int.TryParse(args[0], out port))
{
- config.AddFirewallRule();
- if (args[1].ToLower() == "true")
- config.CreateAndAddCert(Dns.GetHostName());
-
- if ((args.Length >= 3 && args[2] == "reserve") || CConfigHttpApi.IsAdministrator())
- config.ReserveUrl();
+ Console.WriteLine("Usage: VocaluxeServerConfig port isHttps");
+ Environment.Exit(-1);
}
- catch (AuthenticationException)
+ else
{
- ProcessStartInfo proc = new ProcessStartInfo
- {
- UseShellExecute = true,
- WorkingDirectory = Environment.CurrentDirectory,
- FileName = Process.GetCurrentProcess().MainModule.FileName,
- Arguments = args[0] + " " + args[1],
- Verb = "runas",
- CreateNoWindow = true,
- WindowStyle = ProcessWindowStyle.Hidden,
- };
-
+ CConfigHttpApi config = new CConfigHttpApi("Vocaluxe", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Vocaluxe.exe"), "0.0.0.0", port, true);
try
{
- Process.Start(proc);
+ config.AddFirewallRule();
+ if (args[1].ToLower() == "true")
+ config.CreateAndAddCert(Dns.GetHostName());
+
+ if ((args.Length >= 3 && args[2] == "reserve") || CConfigHttpApi.IsAdministrator())
+ config.ReserveUrl();
}
- catch
+ catch (AuthenticationException)
{
- // The user refused the elevation.
- // Do nothing and return directly ...
- Environment.Exit(-1);
+ ProcessStartInfo proc = new ProcessStartInfo
+ {
+ UseShellExecute = true,
+ WorkingDirectory = Environment.CurrentDirectory,
+ FileName = Process.GetCurrentProcess().MainModule.FileName,
+ Arguments = args[0] + " " + args[1],
+ Verb = "runas",
+ CreateNoWindow = true,
+ WindowStyle = ProcessWindowStyle.Hidden,
+ };
+
+ try
+ {
+ Process.Start(proc);
+ }
+ catch
+ {
+ // The user refused the elevation.
+ // Do nothing and return directly ...
+ Environment.Exit(-1);
+ }
}
}
}
+ catch (Exception e)
+ {
+ MessageBox.Show("Error while installing server: " + e.Message);
+ }
}
}
}
\ No newline at end of file
diff --git a/WebserverInitalConfig/WebserverInitalConfig.csproj b/WebserverInitalConfig/WebserverInitalConfig.csproj
index 2f48f927..5405cbe2 100644
--- a/WebserverInitalConfig/WebserverInitalConfig.csproj
+++ b/WebserverInitalConfig/WebserverInitalConfig.csproj
@@ -41,16 +41,13 @@
True
..\Output\Interop.NetFwTypeLib.dll
-
- False
- ..\Output\Security.dll
-
False
..\Output\Security.Cryptography.dll
+