Skip to content

Commit

Permalink
Introduce a new .NET 9.0 TFM and use the new X509CertificateLoader API
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinchalet committed Sep 15, 2024
1 parent 066ef12 commit ef2e02e
Show file tree
Hide file tree
Showing 19 changed files with 243 additions and 100 deletions.
19 changes: 13 additions & 6 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -107,35 +107,42 @@

<NetCoreTargetFrameworks Condition=" '$(NetCoreTargetFrameworks)' == '' ">
net6.0;
net8.0
net8.0;
net9.0
</NetCoreTargetFrameworks>

<NetCoreAndroidTargetFrameworks
Condition=" '$(NetCoreAndroidTargetFrameworks)' == '' And '$(SupportsAndroidTargeting)' == 'true' ">
net8.0-android34.0
net8.0-android34.0;
net9.0-android35.0
</NetCoreAndroidTargetFrameworks>

<NetCoreIOSTargetFrameworks
Condition=" '$(NetCoreIOSTargetFrameworks)' == '' And '$(SupportsIOSTargeting)' == 'true' ">
net8.0-ios17.5
net8.0-ios17.5;
net9.0-ios17.5
</NetCoreIOSTargetFrameworks>

<NetCoreMacCatalystTargetFrameworks
Condition=" '$(NetCoreMacCatalystTargetFrameworks)' == '' And '$(SupportsMacCatalystTargeting)' == 'true' ">
net8.0-maccatalyst17.5
net8.0-maccatalyst17.5;
net9.0-maccatalyst17.5
</NetCoreMacCatalystTargetFrameworks>

<NetCoreMacOSTargetFrameworks
Condition=" '$(NetCoreMacOSTargetFrameworks)' == '' And '$(SupportsMacOSTargeting)' == 'true' ">
net8.0-macos14.5
net8.0-macos14.5;
net9.0-macos14.5
</NetCoreMacOSTargetFrameworks>

<NetCoreWindowsTargetFrameworks
Condition=" '$(NetCoreWindowsTargetFrameworks)' == '' And '$(SupportsWindowsTargeting)' == 'true' ">
net6.0-windows7.0;
net6.0-windows10.0.17763;
net8.0-windows7.0;
net8.0-windows10.0.17763
net8.0-windows10.0.17763;
net9.0-windows7.0;
net9.0-windows10.0.17763
</NetCoreWindowsTargetFrameworks>

<NetStandardTargetFrameworks Condition=" '$(NetStandardTargetFrameworks)' == '' ">
Expand Down
5 changes: 5 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@
<DefineConstants>$(DefineConstants);SUPPORTS_TIME_PROVIDER</DefineConstants>
</PropertyGroup>

<PropertyGroup
Condition=" ('$(TargetFrameworkIdentifier)' == '.NETCoreApp' And $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '9.0'))) ">
<DefineConstants>$(DefineConstants);SUPPORTS_CERTIFICATE_LOADER</DefineConstants>
</PropertyGroup>

<PropertyGroup
Condition=" ('$(TargetFrameworkIdentifier)' == '.NETCoreApp' And $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '5.0')) And
'$(TargetPlatformIdentifier)' == 'Android' And '$(TargetPlatformVersion)' != '' And
Expand Down
72 changes: 60 additions & 12 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -304,26 +304,74 @@
<PackageVersion Include="Moq" Version="4.18.4" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />

<!--
Note: OpenIddict uses PolySharp to dynamically generate polyfills for types that are not available on
some of the targeted TFMs (e.g Index, Range or nullable attributes on .NET Framework/.NET Standard).
-->
<GlobalPackageReference Include="PolySharp" Condition=" '$(DisablePolySharp)' != 'true' " Version="1.13.1" />
</ItemGroup>

<!--
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
█████ ▀██ ██ ▄▄▄█▄▄ ▄▄███▀▄▄▀████ ▄▄ ██
█▀▀██ █ █ ██ ▄▄▄███ █████▄▀▀ █▀▀█ ▀▄ ██
█▄▄██ ██▄ ██ ▀▀▀███ ██████▀▀▄█▄▄█ ▀▀ ██
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
-->

<ItemGroup Label="Package versions for .NET 9.0"
Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' And $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '9.0')) ">
<PackageVersion Include="EntityFramework" Version="6.5.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.0-rc.1.24451.1" />
<PackageVersion Include="Microsoft.Extensions.Caching.Abstractions" Version="9.0.0-rc.1.24431.7" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="9.0.0-rc.1.24431.7" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.0-rc.1.24431.7" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.0-rc.1.24431.7" />
<PackageVersion Include="Microsoft.Extensions.Http.Polly" Version="9.0.0-rc.1.24452.1" />
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="9.0.0-preview.8.24460.1" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.0-rc.1.24431.7" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="9.0.0-rc.1.24431.7" />
<PackageVersion Include="Microsoft.Extensions.Primitives" Version="9.0.0-rc.1.24431.7" />
<PackageVersion Include="Microsoft.Extensions.WebEncoders" Version="9.0.0-rc.1.24452.1" />
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.0.1" />
<PackageVersion Include="Microsoft.IdentityModel.Protocols" Version="8.0.1" />
<PackageVersion Include="Microsoft.IdentityModel.Tokens" Version="8.0.1" />
<PackageVersion Include="Microsoft.Net.Http.Headers" Version="9.0.0-rc.1.24452.1" />
<PackageVersion Include="MongoDB.Bson" Version="2.20.0" />
<PackageVersion Include="MongoDB.Driver" Version="2.20.0" />
<PackageVersion Include="Quartz.Extensions.DependencyInjection" Version="3.5.0" />
<PackageVersion Include="Xamarin.AndroidX.Browser" Version="1.8.0.4" />

<!--
Note: the following references are exclusively used in the test projects:
-->
<PackageVersion Include="AngleSharp" Version="0.17.1" />
<PackageVersion Include="MartinCostello.Logging.XUnit" Version="0.3.0" />
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="9.0.0-rc.1.24452.1" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0-rc.1.24431.7" />
<PackageVersion Include="Moq" Version="4.18.4" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />

<!--
Note: the following references are exclusively used in the samples:
-->
<PackageVersion Include="Dapplo.Microsoft.Extensions.Hosting.AppServices" Version="1.0.14" />
<PackageVersion Include="Dapplo.Microsoft.Extensions.Hosting.WinForms" Version="1.0.14" />
<PackageVersion Include="Dapplo.Microsoft.Extensions.Hosting.Wpf" Version="1.0.14" />
<PackageVersion Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.7" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.7" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageVersion Include="Microsoft.Maui.Controls" Version="8.0.70" />
<PackageVersion Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.70" />
<PackageVersion Include="Quartz.Extensions.Hosting" Version="3.5.0" />
<PackageVersion Include="Spectre.Console" Version="0.48.0" />
<PackageVersion Include="Dapplo.Microsoft.Extensions.Hosting.AppServices" Version="1.0.14" />
<PackageVersion Include="Dapplo.Microsoft.Extensions.Hosting.WinForms" Version="1.0.14" />
<PackageVersion Include="Dapplo.Microsoft.Extensions.Hosting.Wpf" Version="1.0.14" />
<PackageVersion Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="9.0.0-rc.1.24452.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.0-rc.1.24451.1" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.0-rc.1.24431.7" />
<PackageVersion Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0-rc.1.24431.7" />
<PackageVersion Include="Microsoft.Maui.Controls" Version="9.0.0-rc.1.24453.9" />
<PackageVersion Include="Microsoft.Maui.Controls.Compatibility" Version="9.0.0-rc.1.24453.9" />
<PackageVersion Include="Quartz.Extensions.Hosting" Version="3.5.0" />
<PackageVersion Include="Spectre.Console" Version="0.48.0" />

<!--
Note: OpenIddict uses PolySharp to dynamically generate polyfills for types that are not available on
some of the targeted TFMs (e.g Index, Range or nullable attributes on .NET Framework/.NET Standard).
-->
<GlobalPackageReference Include="PolySharp" Condition=" '$(DisablePolySharp)' != 'true' " Version="1.13.1" />
<GlobalPackageReference Include="PolySharp" Condition=" '$(DisablePolySharp)' != 'true' " Version="1.13.1" />
</ItemGroup>

<!--
Expand Down
30 changes: 16 additions & 14 deletions WorkloadRollback.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
"microsoft.net.sdk.android": "34.0.113/8.0.100",
"microsoft.net.sdk.ios": "17.5.8020/8.0.100",
"microsoft.net.sdk.maccatalyst": "17.5.8020/8.0.100",
"microsoft.net.sdk.macos": "14.5.8020/8.0.100",
"microsoft.net.sdk.maui": "8.0.72/8.0.100",
"microsoft.net.sdk.tvos": "17.5.8020/8.0.100",
"microsoft.net.workload.mono.toolchain.current": "8.0.8/8.0.100",
"microsoft.net.workload.emscripten.current": "8.0.8/8.0.100",
"microsoft.net.workload.emscripten.net6": "8.0.8/8.0.100",
"microsoft.net.workload.emscripten.net7": "8.0.8/8.0.100",
"microsoft.net.workload.mono.toolchain.net6": "8.0.8/8.0.100",
"microsoft.net.workload.mono.toolchain.net7": "8.0.8/8.0.100",
"microsoft.net.sdk.aspire": "8.1.0/8.0.100"
}
"microsoft.net.sdk.android": "35.0.0-rc.1.80/9.0.100-rc.1",
"microsoft.net.sdk.ios": "17.5.9270-net9-rc1/9.0.100-rc.1",
"microsoft.net.sdk.maccatalyst": "17.5.9270-net9-rc1/9.0.100-rc.1",
"microsoft.net.sdk.macos": "14.5.9270-net9-rc1/9.0.100-rc.1",
"microsoft.net.sdk.maui": "9.0.0-rc.1.24453.9/9.0.100-rc.1",
"microsoft.net.sdk.tvos": "17.5.9270-net9-rc1/9.0.100-rc.1",
"microsoft.net.workload.mono.toolchain.current": "9.0.0-rc.1.24431.7/9.0.100-rc.1",
"microsoft.net.workload.emscripten.current": "9.0.0-rc.1.24430.3/9.0.100-rc.1",
"microsoft.net.workload.emscripten.net6": "9.0.0-rc.1.24430.3/9.0.100-rc.1",
"microsoft.net.workload.emscripten.net7": "9.0.0-rc.1.24430.3/9.0.100-rc.1",
"microsoft.net.workload.emscripten.net8": "9.0.0-rc.1.24430.3/9.0.100-rc.1",
"microsoft.net.workload.mono.toolchain.net6": "9.0.0-rc.1.24431.7/9.0.100-rc.1",
"microsoft.net.workload.mono.toolchain.net7": "9.0.0-rc.1.24431.7/9.0.100-rc.1",
"microsoft.net.workload.mono.toolchain.net8": "9.0.0-rc.1.24431.7/9.0.100-rc.1",
"microsoft.net.sdk.aspire": "8.2.0/8.0.100"
}
Original file line number Diff line number Diff line change
Expand Up @@ -611,10 +611,7 @@ public sealed partial class {{ provider.name }}
/// </summary>
/// <param name=""stream"">The stream containing the certificate.</param>
/// <param name=""password"">The password used to open the certificate.</param>
/// <param name=""flags"">
/// An enumeration of flags indicating how and where
/// to store the private key of the certificate.
/// </param>
/// <param name=""flags"">An enumeration of flags indicating how and where to store the private key of the certificate.</param>
/// <returns>The <see cref=""OpenIddictClientWebIntegrationBuilder.{{ provider.name }}""/> instance.</returns>
{{~ if setting.obsolete ~}}
[Obsolete(""This option is no longer supported and will be removed in a future version."")]
Expand All @@ -629,7 +626,17 @@ public sealed partial class {{ provider.name }}
using var buffer = new MemoryStream();
stream.CopyTo(buffer);
return Set{{ setting.property_name }}(new X509Certificate2(buffer.ToArray(), password, flags));
#if SUPPORTS_CERTIFICATE_LOADER
var certificate = X509Certificate2.GetCertContentType(buffer.ToArray()) switch
{
X509ContentType.Pkcs12 => X509CertificateLoader.LoadPkcs12(buffer.ToArray(), password, flags),
_ => throw new InvalidOperationException(SR.GetResourceString(SR.ID0454))
};
#else
var certificate = new X509Certificate2(buffer.ToArray(), password, flags);
#endif
return Set{{ setting.property_name }}(certificate);
}
/// <summary>
Expand Down
7 changes: 4 additions & 3 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"sdk": {
"version": "8.0.303",
"version": "9.0.100-rc.1.24452.12",
"allowPrerelease": true,
"rollForward": "major"
},

"tools": {
"dotnet": "8.0.303",
"dotnet": "9.0.100-rc.1.24452.12",

"runtimes": {
"aspnetcore": [
"6.0.32"
"6.0.32",
"8.0.8"
]
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net48;net8.0</TargetFrameworks>
<TargetFrameworks>net48;net9.0</TargetFrameworks>
<Nullable>disable</Nullable>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net48;net8.0</TargetFrameworks>
<TargetFrameworks>net48;net9.0</TargetFrameworks>
<TypeScriptEnabled>false</TypeScriptEnabled>
<Nullable>disable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net48;net8.0</TargetFrameworks>
<TargetFrameworks>net48;net9.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
7 changes: 2 additions & 5 deletions sandbox/OpenIddict.Sandbox.Maui.Client/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ namespace OpenIddict.Sandbox.Maui.Client;

public partial class App : Application
{
public App()
{
InitializeComponent();
public App() => InitializeComponent();

MainPage = new AppShell();
}
protected override Window CreateWindow(IActivationState? activationState) => new(new AppShell());
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks Condition=" '$(SupportsWindowsTargeting)' == 'true' ">net8.0-windows10.0.19041</TargetFrameworks>
<TargetFrameworks Condition=" '$(SupportsIOSTargeting)' == 'true' ">$(TargetFrameworks);net8.0-ios17.5</TargetFrameworks>
<TargetFrameworks Condition=" '$(SupportsMacCatalystTargeting)' == 'true' ">$(TargetFrameworks);net8.0-maccatalyst17.5</TargetFrameworks>
<TargetFrameworks Condition=" '$(SupportsWindowsTargeting)' == 'true' ">net9.0-windows10.0.19041</TargetFrameworks>
<TargetFrameworks Condition=" '$(SupportsIOSTargeting)' == 'true' ">$(TargetFrameworks);net9.0-ios17.5</TargetFrameworks>
<TargetFrameworks Condition=" '$(SupportsMacCatalystTargeting)' == 'true' ">$(TargetFrameworks);net9.0-maccatalyst17.5</TargetFrameworks>
<UseMaui Condition=" '$(TargetFrameworks)' != '' ">true</UseMaui>
<TargetFrameworks Condition=" '$(TargetFrameworks)' == '' ">net8.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(TargetFrameworks)' == '' ">net9.0</TargetFrameworks>
<SingleProject>true</SingleProject>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFrameworks>net48</TargetFrameworks>
<TargetFrameworks Condition=" '$(SupportsWindowsTargeting)' == 'true' ">$(TargetFrameworks);net8.0-windows7.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(SupportsWindowsTargeting)' == 'true' ">$(TargetFrameworks);net9.0-windows7.0</TargetFrameworks>
<UseWindowsForms>true</UseWindowsForms>
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFrameworks>net48</TargetFrameworks>
<TargetFrameworks Condition=" '$(SupportsWindowsTargeting)' == 'true' ">$(TargetFrameworks);net8.0-windows10.0.17763</TargetFrameworks>
<TargetFrameworks Condition=" '$(SupportsWindowsTargeting)' == 'true' ">$(TargetFrameworks);net9.0-windows10.0.17763</TargetFrameworks>
<UseWPF>true</UseWPF>
<EnableDefaultApplicationDefinition>false</EnableDefaultApplicationDefinition>
</PropertyGroup>
Expand Down
3 changes: 3 additions & 0 deletions src/OpenIddict.Abstractions/OpenIddictResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1695,6 +1695,9 @@ To apply post-logout redirection responses, create a class implementing 'IOpenId
<data name="ID0453" xml:space="preserve">
<value>The specified intent doesn't contain a valid data URI.</value>
</data>
<data name="ID0454" xml:space="preserve">
<value>The format of the specified certificate is not supported.</value>
</data>
<data name="ID2000" xml:space="preserve">
<value>The security token is missing.</value>
</data>
Expand Down
Loading

0 comments on commit ef2e02e

Please sign in to comment.