fix Kestrel https option for netstandard 2.0

tested with Ua Expert against standard and ref server
This commit is contained in:
Martin Regen
2017-09-11 14:20:48 +02:00
parent a8569d0f03
commit c23a112411
3 changed files with 23 additions and 12 deletions
@@ -2,7 +2,6 @@
<PropertyGroup>
<TargetFrameworks>net46;netstandard1.4;netstandard2.0</TargetFrameworks>
<DefineConstants Condition="'$(TargetFramework)' == 'netstandard2.0'">$(DefineConstants);NO_HTTPS</DefineConstants>
<AssemblyName>Opc.Ua.Server</AssemblyName>
<PackageId>Opc.Ua.Server</PackageId>
</PropertyGroup>
-1
View File
@@ -3,7 +3,6 @@
<PropertyGroup>
<TargetFrameworks>net46;netstandard1.4;netstandard2.0</TargetFrameworks>
<DefineConstants>$(DefineConstants);NET_STANDARD</DefineConstants>
<DefineConstants Condition="'$(TargetFramework)' == 'netstandard2.0'">$(DefineConstants);NO_HTTPS</DefineConstants>
<AssemblyName>Opc.Ua.Core</AssemblyName>
<PackageId>Opc.Ua.Core</PackageId>
</PropertyGroup>
+23 -10
View File
@@ -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<Startup>();
m_host.Start(Utils.ReplaceLocalhost(m_uri.ToString()));