Skip to content

Commit 5c1cda0

Browse files
committed
Implement native mTLS client authentication support in the server stack
1 parent 6962772 commit 5c1cda0

File tree

60 files changed

+4124
-850
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+4124
-850
lines changed

Directory.Build.targets

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
<DefineConstants>$(DefineConstants);SUPPORTS_HTTP_CLIENT_DEFAULT_REQUEST_VERSION_POLICY</DefineConstants>
6969
<DefineConstants>$(DefineConstants);SUPPORTS_HTTP_CLIENT_RESILIENCE</DefineConstants>
7070
<DefineConstants>$(DefineConstants);SUPPORTS_INT32_RANDOM_NUMBER_GENERATOR_METHODS</DefineConstants>
71+
<DefineConstants>$(DefineConstants);SUPPORTS_KESTREL_TLS_HANDSHAKE_CALLBACK_OPTIONS</DefineConstants>
7172
<DefineConstants>$(DefineConstants);SUPPORTS_MULTIPLE_VALUES_IN_QUERYHELPERS</DefineConstants>
7273
<DefineConstants>$(DefineConstants);SUPPORTS_NAMED_PIPE_STATIC_FACTORY_WITH_ACL</DefineConstants>
7374
<DefineConstants>$(DefineConstants);SUPPORTS_ONE_SHOT_HASHING_METHODS</DefineConstants>
@@ -78,6 +79,9 @@
7879
<DefineConstants>$(DefineConstants);SUPPORTS_TEXT_ELEMENT_ENUMERATOR</DefineConstants>
7980
<DefineConstants>$(DefineConstants);SUPPORTS_VALUETASK_COMPLETED_TASK</DefineConstants>
8081
<DefineConstants>$(DefineConstants);SUPPORTS_WINFORMS_TASK_DIALOG</DefineConstants>
82+
<DefineConstants>$(DefineConstants);SUPPORTS_X509_CHAIN_POLICY_CUSTOM_TRUST_STORE</DefineConstants>
83+
<DefineConstants>$(DefineConstants);SUPPORTS_X509_CHAIN_POLICY_DOWNLOAD_MODE</DefineConstants>
84+
<DefineConstants>$(DefineConstants);SUPPORTS_X509_CHAIN_POLICY_TRUST_MODE</DefineConstants>
8185
<DefineConstants>$(DefineConstants);SUPPORTS_ZLIB_COMPRESSION</DefineConstants>
8286
</PropertyGroup>
8387

@@ -114,6 +118,8 @@
114118
<DefineConstants>$(DefineConstants);SUPPORTS_JSON_ELEMENT_DEEP_EQUALS</DefineConstants>
115119
<DefineConstants>$(DefineConstants);SUPPORTS_JSON_ELEMENT_PROPERTY_COUNT</DefineConstants>
116120
<DefineConstants>$(DefineConstants);SUPPORTS_TYPE_DESCRIPTOR_TYPE_REGISTRATION</DefineConstants>
121+
<DefineConstants>$(DefineConstants);SUPPORTS_X509_CHAIN_POLICY_CLONING</DefineConstants>
122+
<DefineConstants>$(DefineConstants);SUPPORTS_X509_CHAIN_POLICY_VERIFICATION_TIME_MODE</DefineConstants>
117123
</PropertyGroup>
118124

119125
<PropertyGroup

gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationGenerator.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ public sealed partial class {{ provider.name }}
628628
store.Open(OpenFlags.ReadOnly);
629629
630630
return store.Certificates.Find(X509FindType.FindByThumbprint, thumbprint, validOnly: false)
631-
.OfType<X509Certificate2>()
631+
.Cast<X509Certificate2>()
632632
.SingleOrDefault();
633633
}
634634
}
@@ -652,7 +652,7 @@ public sealed partial class {{ provider.name }}
652652
653653
return Set{{ setting.property_name }}(
654654
store.Certificates.Find(X509FindType.FindByThumbprint, thumbprint, validOnly: false)
655-
.OfType<X509Certificate2>()
655+
.Cast<X509Certificate2>()
656656
.SingleOrDefault() ?? throw new InvalidOperationException(SR.GetResourceString(SR.ID0066)));
657657
}
658658
{{~ else if setting.clr_type == 'bool' ~}}
@@ -1163,8 +1163,7 @@ public static partial void ConfigureProvider(OpenIddictClientRegistration regist
11631163
if (settings.{{ setting.property_name }} is not null)
11641164
{
11651165
// If the signing key is an asymmetric security key, ensure it has a private key.
1166-
if (settings.{{ setting.property_name }} is AsymmetricSecurityKey asymmetricSecurityKey &&
1167-
asymmetricSecurityKey.PrivateKeyStatus is PrivateKeyStatus.DoesNotExist)
1166+
if (settings.{{ setting.property_name }} is AsymmetricSecurityKey { PrivateKeyStatus: PrivateKeyStatus.DoesNotExist })
11681167
{
11691168
throw new InvalidOperationException(SR.GetResourceString(SR.ID0067));
11701169
}

sandbox/OpenIddict.Sandbox.AspNet.Client/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void Configuration(IAppBuilder app)
7171
ProviderDisplayName = "Local OIDC server",
7272

7373
ClientId = "mvc",
74-
ClientSecret = "901564A5-E7FE-42CB-B10D-61EF6A8F3654",
74+
ClientSecret = "emCimpdc9SeOaZzN5jzm4_eek-STF6VenfVlKO1_qt0",
7575
Scopes = { Scopes.Email, Scopes.Profile, Scopes.OfflineAccess, "demo_api" },
7676

7777
RedirectUri = new Uri("callback/login/local", UriKind.Relative),

sandbox/OpenIddict.Sandbox.AspNet.Server/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public void Configuration(IAppBuilder app)
199199
{
200200
ApplicationType = ApplicationTypes.Web,
201201
ClientId = "mvc",
202-
ClientSecret = "901564A5-E7FE-42CB-B10D-61EF6A8F3654",
202+
ClientSecret = "emCimpdc9SeOaZzN5jzm4_eek-STF6VenfVlKO1_qt0",
203203
ClientType = ClientTypes.Confidential,
204204
ConsentType = ConsentTypes.Systematic,
205205
DisplayName = "MVC client application",

0 commit comments

Comments
 (0)