diff --git a/SampleApplications/SDK/Opc.Ua.Server/Opc.Ua.Server.csproj b/SampleApplications/SDK/Opc.Ua.Server/Opc.Ua.Server.csproj index 0fc13e4959..09f5525491 100644 --- a/SampleApplications/SDK/Opc.Ua.Server/Opc.Ua.Server.csproj +++ b/SampleApplications/SDK/Opc.Ua.Server/Opc.Ua.Server.csproj @@ -2,7 +2,6 @@ net46;netstandard1.4;netstandard2.0 - $(DefineConstants);NO_HTTPS Opc.Ua.Server Opc.Ua.Server diff --git a/Stack/Opc.Ua.Core/Opc.Ua.Core.csproj b/Stack/Opc.Ua.Core/Opc.Ua.Core.csproj index 6f58d16035..3036d06f6c 100644 --- a/Stack/Opc.Ua.Core/Opc.Ua.Core.csproj +++ b/Stack/Opc.Ua.Core/Opc.Ua.Core.csproj @@ -3,7 +3,6 @@ net46;netstandard1.4;netstandard2.0 $(DefineConstants);NET_STANDARD - $(DefineConstants);NO_HTTPS Opc.Ua.Core Opc.Ua.Core diff --git a/Stack/Opc.Ua.Core/Stack/Https/HttpsListener.cs b/Stack/Opc.Ua.Core/Stack/Https/HttpsListener.cs index a9da2c6f9f..d7cf2f2b56 100644 --- a/Stack/Opc.Ua.Core/Stack/Https/HttpsListener.cs +++ b/Stack/Opc.Ua.Core/Stack/Https/HttpsListener.cs @@ -23,18 +23,22 @@ #if !NO_HTTPS -using System; -using System.Net; -using System.IO; -using System.Security.Cryptography.X509Certificates; -using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.Logging; +using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using System.Threading.Tasks; using Microsoft.AspNetCore.Server.Kestrel.Https; +using Microsoft.Extensions.Logging; +using System; +using System.IO; +using System.Net; using System.Security.Authentication; -using System.Collections.Generic; +using System.Security.Cryptography.X509Certificates; +using System.Threading.Tasks; + +#if NETSTANDARD2_0 +using Microsoft.AspNetCore.Server.Kestrel.Core; +#endif + namespace Opc.Ua.Bindings { @@ -175,18 +179,27 @@ namespace Opc.Ua.Bindings { Startup.Listener = this; m_host = new WebHostBuilder(); - +#if NETSTANDARD2_0 + m_host.UseKestrel(options => + { + options.Listen(IPAddress.Loopback, m_uri.Port, listenOptions => + { + listenOptions.NoDelay = true; + listenOptions.UseHttps(m_serverCert); + }); + }); +#else HttpsConnectionFilterOptions httpsOptions = new HttpsConnectionFilterOptions(); httpsOptions.CheckCertificateRevocation = false; httpsOptions.ClientCertificateMode = ClientCertificateMode.NoCertificate; httpsOptions.ServerCertificate = m_serverCert; httpsOptions.SslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12; - m_host.UseKestrel(options => { options.NoDelay = true; options.UseHttps(httpsOptions); }); +#endif m_host.UseContentRoot(Directory.GetCurrentDirectory()); m_host.UseStartup(); m_host.Start(Utils.ReplaceLocalhost(m_uri.ToString()));