Skip to content

Commit

Permalink
Use FrameworkReference for kestrel package for .NET Core App >= 3.1 (#…
Browse files Browse the repository at this point in the history
…1646)

- Kestrel server is end of life for .NET Core 2.1, only support for .NET framework and netstandard2.0
- Use FrameworkReference to include ASPNET services for .NET Core 3.x and later
- adjust the code signing for bindings.https
- deprecate complextypes.symbols package

- note: only netcoreapp3.1 and net6.0 frameworks yet support latest kestrel and allow to use MS.Ext.Logging library >=5.x with bindings.https. If netstandard2.0 or net462 is used, the Microsoft.Extensions.Logging library >= 3.x cause a TypeException in Microsoft...HttpHeader because a required class became obsolete in Platform.Extensions.
  • Loading branch information
mregen committed Dec 23, 2021
1 parent 5bcadf4 commit 0011f48
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 61 deletions.
7 changes: 3 additions & 4 deletions .azurepipelines/signlistDebug.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@ Stack\Opc.Ua.Core\bin\Debug\netstandard2.0\Opc.Ua.Core.dll
Stack\Opc.Ua.Core\bin\Debug\netstandard2.1\Opc.Ua.Core.dll
Stack\Opc.Ua.Core\bin\Debug\net462\Opc.Ua.Core.dll
Stack\Opc.Ua.Core\bin\Debug\net6.0\Opc.Ua.Core.dll
Stack\Opc.Ua.Bindings.Https\bin\Debug\netstandard2.0\Opc.Ua.Bindings.Https.dll
Stack\Opc.Ua.Bindings.Https\bin\Debug\netstandard2.1\Opc.Ua.Bindings.Https.dll
Stack\Opc.Ua.Bindings.Https\bin\Debug\net462\Opc.Ua.Bindings.Https.dll
Stack\Opc.Ua.Bindings.Https\bin\Debug\netstandard2.0\Opc.Ua.Bindings.Https.dll
Stack\Opc.Ua.Bindings.Https\bin\Debug\netcoreapp3.1\Opc.Ua.Bindings.Https.dll
Stack\Opc.Ua.Bindings.Https\bin\Debug\net6.0\Opc.Ua.Bindings.Https.dll
Libraries\Opc.Ua.Server\bin\Debug\netstandard2.0\Opc.Ua.Server.dll
Libraries\Opc.Ua.Server\bin\Debug\netstandard2.1\Opc.Ua.Server.dll
Libraries\Opc.Ua.Server\bin\Debug\net462\Opc.Ua.Server.dll
Libraries\Opc.Ua.Server\bin\Debug\net462\Opc.Ua.Server.dll
Libraries\Opc.Ua.Server\bin\Debug\net6.0\Opc.Ua.Server.dll
Libraries\Opc.Ua.Client\bin\Debug\netstandard2.0\Opc.Ua.Client.dll
Libraries\Opc.Ua.Client\bin\Debug\netstandard2.1\Opc.Ua.Client.dll
Libraries\Opc.Ua.Client\bin\Debug\net462\Opc.Ua.Client.dll
Libraries\Opc.Ua.Client\bin\Debug\net6.0\Opc.Ua.Client.dll
Libraries\Opc.Ua.Client.ComplexTypes\bin\Debug\netcoreapp2.1\Opc.Ua.Client.ComplexTypes.dll
Libraries\Opc.Ua.Client.ComplexTypes\bin\Debug\netstandard2.1\Opc.Ua.Client.ComplexTypes.dll
Libraries\Opc.Ua.Client.ComplexTypes\bin\Debug\net462\Opc.Ua.Client.ComplexTypes.dll
Libraries\Opc.Ua.Client.ComplexTypes\bin\Debug\net6.0\Opc.Ua.Client.ComplexTypes.dll
Expand Down
5 changes: 2 additions & 3 deletions .azurepipelines/signlistRelease.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ Stack\Opc.Ua.Core\bin\Release\netstandard2.0\Opc.Ua.Core.dll
Stack\Opc.Ua.Core\bin\Release\netstandard2.1\Opc.Ua.Core.dll
Stack\Opc.Ua.Core\bin\Release\net462\Opc.Ua.Core.dll
Stack\Opc.Ua.Core\bin\Release\net6.0\Opc.Ua.Core.dll
Stack\Opc.Ua.Bindings.Https\bin\Release\netstandard2.0\Opc.Ua.Bindings.Https.dll
Stack\Opc.Ua.Bindings.Https\bin\Release\netstandard2.1\Opc.Ua.Bindings.Https.dll
Stack\Opc.Ua.Bindings.Https\bin\Release\net462\Opc.Ua.Bindings.Https.dll
Stack\Opc.Ua.Bindings.Https\bin\Release\netstandard2.0\Opc.Ua.Bindings.Https.dll
Stack\Opc.Ua.Bindings.Https\bin\Release\netcoreapp3.1\Opc.Ua.Bindings.Https.dll
Stack\Opc.Ua.Bindings.Https\bin\Release\net6.0\Opc.Ua.Bindings.Https.dll
Libraries\Opc.Ua.Server\bin\Release\netstandard2.0\Opc.Ua.Server.dll
Libraries\Opc.Ua.Server\bin\Release\netstandard2.1\Opc.Ua.Server.dll
Expand All @@ -14,7 +14,6 @@ Libraries\Opc.Ua.Client\bin\Release\netstandard2.0\Opc.Ua.Client.dll
Libraries\Opc.Ua.Client\bin\Release\netstandard2.1\Opc.Ua.Client.dll
Libraries\Opc.Ua.Client\bin\Release\net462\Opc.Ua.Client.dll
Libraries\Opc.Ua.Client\bin\Release\net6.0\Opc.Ua.Client.dll
Libraries\Opc.Ua.Client.ComplexTypes\bin\Release\netcoreapp2.1\Opc.Ua.Client.ComplexTypes.dll
Libraries\Opc.Ua.Client.ComplexTypes\bin\Release\netstandard2.1\Opc.Ua.Client.ComplexTypes.dll
Libraries\Opc.Ua.Client.ComplexTypes\bin\Release\net462\Opc.Ua.Client.ComplexTypes.dll
Libraries\Opc.Ua.Client.ComplexTypes\bin\Release\net6.0\Opc.Ua.Client.ComplexTypes.dll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@

<ItemGroup Condition=" '$(NoHttps)' != 'true' ">
<ProjectReference Include="..\..\Stack\Opc.Ua.Bindings.Https\Opc.Ua.Bindings.Https.csproj" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.21" />
</ItemGroup>

<ItemGroup Condition=" '$(NoHttps)' == 'true' ">
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\ConsoleReferenceServer\ConsoleUtils.cs" Exclude="bin\**;obj\**;**\*.xproj;packages\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Mono.Options" Version="6.12.0.148" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.Expressions" Version="3.2.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,8 @@

<ItemGroup Condition=" '$(NoHttps)' != 'true' ">
<ProjectReference Include="..\..\Stack\Opc.Ua.Bindings.Https\Opc.Ua.Bindings.Https.csproj" />
<!-- Due to a compatibilty issue of the kestrel server the .NET Core 3.1 package must be used -->
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.21" />
</ItemGroup>

<ItemGroup Condition=" '$(NoHttps)' == 'true' ">
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Stack\Opc.Ua.Core\Opc.Ua.Core.csproj" />
Expand All @@ -33,6 +28,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Mono.Options" Version="6.12.0.148" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.Expressions" Version="3.2.1" />
Expand Down
35 changes: 22 additions & 13 deletions Stack/Opc.Ua.Bindings.Https/Opc.Ua.Bindings.Https.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>$(LibTargetFrameworks)</TargetFrameworks>
<TargetFrameworks>$(HttpsTargetFrameworks)</TargetFrameworks>
<AssemblyName>Opc.Ua.Bindings.Https</AssemblyName>
<PackageId>OPCFoundation.NetStandard.Opc.Ua.Bindings.Https</PackageId>
<RootNamespace>Opc.Ua.Bindings</RootNamespace>
<Description>OPC UA Https Binding Library</Description>
<IsPackable>true</IsPackable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<PackageId>$(PackageId).Debug</PackageId>
</PropertyGroup>
Expand All @@ -18,6 +18,25 @@
<DefineConstants>$(DefineConstants);SIGNASSEMBLY</DefineConstants>
</PropertyGroup>

<Choose>
<When Condition="'$(TargetFramework)' == 'netcoreapp3.1' OR '$(TargetFramework)' == 'net5.0' OR '$(TargetFramework)' == 'net6.0'">
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Core" Version="2.1.25" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets" Version="2.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Https" Version="2.1.3" />
<PackageReference Include="System.Io.Pipelines" Version="6.0.1" />
<PackageReference Include="System.Text.Encodings.Web" Version="6.0.0" />
</ItemGroup>
</Otherwise>
</Choose>

<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<Reference Include="System.Net.Http" />
</ItemGroup>
Expand All @@ -26,16 +45,6 @@
<Reference Include="System.Net.Http" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Core" Version="2.1.25" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets" Version="2.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Https" Version="2.1.3" />
<PackageReference Include="System.Io.Pipelines" Version="6.0.1" />
<PackageReference Include="System.Text.Encodings.Web" Version="6.0.0" />

</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ public void Open()
{
try
{
Utils.LogInfo("{0} Open {1}.", nameof(HttpsTransportChannel), m_url);

// auto validate server cert, if supported
// if unsupported, the TLS server cert must be trusted by a root CA
var handler = new HttpClientHandler();
Expand Down Expand Up @@ -153,6 +155,8 @@ public void Open()
return false;
};
propertyInfo.SetValue(handler, serverCertificateCustomValidationCallback);

Utils.LogInfo("{0} ServerCertificate callback enabled.", nameof(HttpsTransportChannel));
}
catch (PlatformNotSupportedException)
{
Expand All @@ -174,6 +178,7 @@ public void Open()
/// <inheritdoc/>
public void Close()
{
Utils.LogInfo("{0} Close {1}.", nameof(HttpsTransportChannel), m_url);
m_client?.Dispose();
}

Expand Down Expand Up @@ -209,7 +214,7 @@ public IAsyncResult BeginSendRequest(IServiceRequest request, AsyncCallback call
ByteArrayContent content = new ByteArrayContent(BinaryEncoder.EncodeMessage(request, m_quotas.MessageContext));
content.Headers.ContentType = m_mediaTypeHeaderValue;
if (EndpointDescription?.SecurityPolicyUri != null &&
string.Compare(EndpointDescription.SecurityPolicyUri, SecurityPolicies.None) != 0)
!string.Equals(EndpointDescription.SecurityPolicyUri, SecurityPolicies.None, StringComparison.Ordinal))
{
content.Headers.Add("OPCUA-SecurityPolicy", EndpointDescription.SecurityPolicyUri);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.AspNetCore.Server.Kestrel.Https;
using Microsoft.Extensions.Hosting;


namespace Opc.Ua.Bindings
Expand Down Expand Up @@ -369,7 +369,8 @@ public async Task SendAsync(HttpContext context)
}

if (endpoint == null &&
input.TypeId != DataTypeIds.GetEndpointsRequest)
input.TypeId != DataTypeIds.GetEndpointsRequest &&
input.TypeId != DataTypeIds.FindServersRequest)
{
var message = "Connection refused, invalid security policy.";
Utils.LogError(message);
Expand All @@ -392,7 +393,7 @@ public async Task SendAsync(HttpContext context)
context.Response.ContentLength = response.Length;
context.Response.ContentType = context.Request.ContentType;
context.Response.StatusCode = (int)HttpStatusCode.OK;
#if NETSTANDARD2_1 || NET5_0_OR_GREATER
#if NETSTANDARD2_1 || NET5_0_OR_GREATER || NETCOREAPP3_1_OR_GREATER
await context.Response.Body.WriteAsync(response.AsMemory(0, response.Length)).ConfigureAwait(false);
#else
await context.Response.Body.WriteAsync(response, 0, response.Length).ConfigureAwait(false);
Expand Down
27 changes: 0 additions & 27 deletions nuget/Opc.Ua.Client.ComplexTypes.Symbols.nuspec

This file was deleted.

3 changes: 3 additions & 0 deletions targets.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<TestsTargetFrameworks>net462;netcoreapp3.1;net6.0</TestsTargetFrameworks>
<LibTargetFrameworks>net462;netstandard2.0;netstandard2.1;net6.0</LibTargetFrameworks>
<LibxTargetFrameworks>net462;netstandard2.1;net6.0</LibxTargetFrameworks>
<HttpsTargetFrameworks>net462;netstandard2.0;netcoreapp3.1;net6.0</HttpsTargetFrameworks>
</PropertyGroup>
</When>
<!-- Visual Studio 2019, supports .NET Framework 4.6.2 and .NET Core 3.1 -->
Expand All @@ -25,6 +26,7 @@
<TestsTargetFrameworks>net462;netcoreapp3.1</TestsTargetFrameworks>
<LibTargetFrameworks>net462;netstandard2.0;netstandard2.1</LibTargetFrameworks>
<LibxTargetFrameworks>net462;netstandard2.1</LibxTargetFrameworks>
<HttpsTargetFrameworks>net462;netstandard2.0;netcoreapp3.1</HttpsTargetFrameworks>
</PropertyGroup>
</When>
<!-- Visual Studio 2017 and earlier, support only .NET Framework 4.6.2 because .NET Core 2.x is end of life. -->
Expand All @@ -35,6 +37,7 @@
<TestsTargetFrameworks>net462</TestsTargetFrameworks>
<LibTargetFrameworks>net462</LibTargetFrameworks>
<LibxTargetFrameworks>net462</LibxTargetFrameworks>
<HttpsTargetFrameworks>net462</HttpsTargetFrameworks>
</PropertyGroup>
</Otherwise>
</Choose>
Expand Down

0 comments on commit 0011f48

Please sign in to comment.