diff --git a/src/PepperDash.Core/Logging/DebugWebsocketSink.cs b/src/PepperDash.Core/Logging/DebugWebsocketSink.cs
index 856abbdb..3372970a 100644
--- a/src/PepperDash.Core/Logging/DebugWebsocketSink.cs
+++ b/src/PepperDash.Core/Logging/DebugWebsocketSink.cs
@@ -28,7 +28,7 @@ namespace PepperDash.Core
///
public class DebugWebsocketSink : ILogEventSink
{
- private HttpServer _httpsServer;
+ private WebSocketServer _wsServer;
private string _path = "/debug/join/";
private const string _certificateName = "selfCres";
@@ -38,8 +38,8 @@ namespace PepperDash.Core
{ get
{
- if(_httpsServer == null) return 0;
- return _httpsServer.Port;
+ if(_wsServer == null) return 0;
+ return _wsServer.Port;
}
}
@@ -47,15 +47,15 @@ namespace PepperDash.Core
{
get
{
- if (_httpsServer == null) return "";
- return $"wss://{CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0)}:{_httpsServer.Port}{_httpsServer.WebSocketServices[_path].Path}";
+ if (_wsServer == null) return "";
+ return $"wss://{CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0)}:{_wsServer.Port}{_wsServer.WebSocketServices[_path].Path}";
}
}
///
/// Gets or sets the IsRunning
///
- public bool IsRunning { get => _httpsServer?.IsListening ?? false; }
+ public bool IsRunning { get => _wsServer?.IsListening ?? false; }
private readonly ITextFormatter _textFormatter;
@@ -118,12 +118,12 @@ namespace PepperDash.Core
///
public void Emit(LogEvent logEvent)
{
- if (_httpsServer == null || !_httpsServer.IsListening) return;
+ if (_wsServer == null || !_wsServer.IsListening) return;
var sw = new StringWriter();
_textFormatter.Format(logEvent, sw);
- _httpsServer.WebSocketServices.Broadcast(sw.ToString());
+ _wsServer.WebSocketServices.Broadcast(sw.ToString());
}
@@ -142,17 +142,16 @@ namespace PepperDash.Core
{
try
{
- _httpsServer = new HttpServer(port, true);
-
+ ServerSslConfiguration sslConfig = null;
if (!string.IsNullOrWhiteSpace(certPath))
{
Debug.Console(0, "Assigning SSL Configuration");
- _httpsServer.SslConfiguration = new ServerSslConfiguration(new X509Certificate2(certPath, certPassword))
+ sslConfig = new ServerSslConfiguration(new X509Certificate2(certPath, certPassword))
{
ClientCertificateRequired = false,
CheckCertificateRevocation = false,
- EnabledSslProtocols = SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls,
+ EnabledSslProtocols = SslProtocols.Tls12,
//this is just to test, you might want to actually validate
ClientCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) =>
{
@@ -161,11 +160,18 @@ namespace PepperDash.Core
}
};
}
+
+ _wsServer = new WebSocketServer(port, true);
+ if (sslConfig != null)
+ {
+ _wsServer.SslConfiguration.ServerCertificate = sslConfig.ServerCertificate;
+ }
+
Debug.Console(0, "Adding Debug Client Service");
- _httpsServer.AddWebSocketService(_path);
+ _wsServer.AddWebSocketService(_path);
Debug.Console(0, "Assigning Log Info");
- _httpsServer.Log.Level = LogLevel.Trace;
- _httpsServer.Log.Output = (d, s) =>
+ _wsServer.Log.Level = LogLevel.Trace;
+ _wsServer.Log.Output = (d, s) =>
{
uint level;
@@ -198,7 +204,7 @@ namespace PepperDash.Core
};
Debug.Console(0, "Starting");
- _httpsServer.Start();
+ _wsServer.Start();
Debug.Console(0, "Ready");
}
catch (Exception ex)
@@ -213,9 +219,9 @@ namespace PepperDash.Core
public void StopServer()
{
Debug.Console(0, "Stopping Websocket Server");
- _httpsServer?.Stop();
+ _wsServer?.Stop();
- _httpsServer = null;
+ _wsServer = null;
}
}
diff --git a/src/PepperDash.Core/PepperDash.Core.csproj b/src/PepperDash.Core/PepperDash.Core.csproj
index 875e6275..d35414f6 100644
--- a/src/PepperDash.Core/PepperDash.Core.csproj
+++ b/src/PepperDash.Core/PepperDash.Core.csproj
@@ -5,7 +5,7 @@
PepperDash.Core
PepperDashCore
- net472
+ net8
true
en
bin\$(Configuration)\
@@ -42,18 +42,18 @@
-
-
+
+
global,NewtonsoftJson
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/src/PepperDash.Essentials.Core/PepperDash.Essentials.Core.csproj b/src/PepperDash.Essentials.Core/PepperDash.Essentials.Core.csproj
index a474d8c3..ee84b176 100644
--- a/src/PepperDash.Essentials.Core/PepperDash.Essentials.Core.csproj
+++ b/src/PepperDash.Essentials.Core/PepperDash.Essentials.Core.csproj
@@ -25,7 +25,8 @@
bin\$(Configuration)\PepperDash_Essentials_Core.xml
-
+
+
diff --git a/src/PepperDash.Essentials.Devices.Common/PepperDash.Essentials.Devices.Common.csproj b/src/PepperDash.Essentials.Devices.Common/PepperDash.Essentials.Devices.Common.csproj
index d1776f73..c5a38981 100644
--- a/src/PepperDash.Essentials.Devices.Common/PepperDash.Essentials.Devices.Common.csproj
+++ b/src/PepperDash.Essentials.Devices.Common/PepperDash.Essentials.Devices.Common.csproj
@@ -29,6 +29,7 @@
-
+
+
\ No newline at end of file
diff --git a/src/PepperDash.Essentials.MobileControl.Messengers/PepperDash.Essentials.MobileControl.Messengers.csproj b/src/PepperDash.Essentials.MobileControl.Messengers/PepperDash.Essentials.MobileControl.Messengers.csproj
index 7eaefc16..0d948cc0 100644
--- a/src/PepperDash.Essentials.MobileControl.Messengers/PepperDash.Essentials.MobileControl.Messengers.csproj
+++ b/src/PepperDash.Essentials.MobileControl.Messengers/PepperDash.Essentials.MobileControl.Messengers.csproj
@@ -33,7 +33,8 @@
-
+
+
diff --git a/src/PepperDash.Essentials.MobileControl/PepperDash.Essentials.MobileControl.csproj b/src/PepperDash.Essentials.MobileControl/PepperDash.Essentials.MobileControl.csproj
index 73d648f7..2f8ad112 100644
--- a/src/PepperDash.Essentials.MobileControl/PepperDash.Essentials.MobileControl.csproj
+++ b/src/PepperDash.Essentials.MobileControl/PepperDash.Essentials.MobileControl.csproj
@@ -38,7 +38,8 @@
-
+
+
diff --git a/src/PepperDash.Essentials.MobileControl/WebSocketServer/MobileControlWebsocketServer.cs b/src/PepperDash.Essentials.MobileControl/WebSocketServer/MobileControlWebsocketServer.cs
index 3b55120f..210dc577 100644
--- a/src/PepperDash.Essentials.MobileControl/WebSocketServer/MobileControlWebsocketServer.cs
+++ b/src/PepperDash.Essentials.MobileControl/WebSocketServer/MobileControlWebsocketServer.cs
@@ -1,29 +1,26 @@
-using System;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.IO;
-using System.Linq;
-using System.Net.Http;
+using System.Collections.Concurrent;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using System.Text;
-using Crestron.SimplSharp;
-using Crestron.SimplSharp.WebScripting;
-using Newtonsoft.Json;
-using Org.BouncyCastle.Crypto.Prng;
-using PepperDash.Core;
-using PepperDash.Core.Logging;
using PepperDash.Essentials.Core;
-using PepperDash.Essentials.Core.DeviceTypeInterfaces;
+using System.Collections.Generic;
+using System;
+using System.Net.Http;
+using Crestron.SimplSharp;
+using System.Linq;
+using PepperDash.Core.Logging;
using PepperDash.Essentials.Core.Web;
-using PepperDash.Essentials.RoomBridges;
+using Crestron.SimplSharp.WebScripting;
using PepperDash.Essentials.WebApiHandlers;
-using Serilog.Events;
using WebSocketSharp;
using WebSocketSharp.Net;
using WebSocketSharp.Server;
-
+using PepperDash.Essentials.Core.DeviceTypeInterfaces;
+using System.IO;
+using Newtonsoft.Json;
+using PepperDash.Core;
+using Serilog.Events;
+using PepperDash.Essentials.RoomBridges;
namespace PepperDash.Essentials.WebSocketServer
{
@@ -51,7 +48,7 @@ namespace PepperDash.Essentials.WebSocketServer
private HttpServer _server;
///
- /// Gets the HttpServer instance
+ /// Gets the WebSocketServer instance
///
public HttpServer Server => _server;
@@ -269,24 +266,31 @@ namespace PepperDash.Essentials.WebSocketServer
_server = new HttpServer(Port, false);
- _server.OnGet += Server_OnGet;
- _server.OnOptions += Server_OnOptions;
+
+ _server.OnGet += (sender, e) => Server_OnGet(sender, e);
+
+ _server.OnOptions += (sender, e) => Server_OnOptions(sender, e);
if (_parent.Config.DirectServer.Logging.EnableRemoteLogging)
{
- _server.OnPost += Server_OnPost;
+ _server.OnPost += (sender, e) => Server_OnPost(sender, e);
}
if (_parent.Config.DirectServer.Secure)
{
this.LogInformation("Adding SSL Configuration to server");
- _server.SslConfiguration = new ServerSslConfiguration(new X509Certificate2($"\\user\\{certificateName}.pfx", certificatePassword))
+
+ ServerSslConfiguration sslConfig = null;
+
+ sslConfig = new ServerSslConfiguration(new X509Certificate2($"\\user\\{certificateName}.pfx", certificatePassword))
{
ClientCertificateRequired = false,
CheckCertificateRevocation = false,
EnabledSslProtocols = SslProtocols.Tls12 | SslProtocols.Tls11
};
+
+ _server.SslConfiguration.ServerCertificate = sslConfig.ServerCertificate;
}
_server.Log.Output = (data, message) => Utilities.ConvertWebsocketLog(data, message, this);
diff --git a/src/PepperDash.Essentials/PepperDash.Essentials.csproj b/src/PepperDash.Essentials/PepperDash.Essentials.csproj
index c8a4dc7e..856b881f 100644
--- a/src/PepperDash.Essentials/PepperDash.Essentials.csproj
+++ b/src/PepperDash.Essentials/PepperDash.Essentials.csproj
@@ -51,8 +51,8 @@
-
-
+
+