You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Foundation] Make it possible to customize the X509ChainPolicy when validating certificates in NSUrlSessionHandler. Fixes#23764. (#23767)
* Add a `CertificateChainPolicy` property to `NSUrlSessionHandler` to make it
possible for developers to customize the the policy that is used when
validating certificate chains when using a custom server certificate
validation.
* Also implement `NSUrlSessionHandler.CheckCertificateRevocationList` using
the new `CertificateChainPolicy` property.
Fixes#23764.
/// <summary>Gets or sets a value that indicates whether the certificate is checked against the certificate authority revocation list.</summary>
591
+
/// <remarks>
592
+
/// <para>This is the same as setting CertificateChainPolicy.RevocationMode = X509RevocationMode.Online (if enabling the check) or X509RevocationMode.NoCheck (if disabling the check).</para>
593
+
/// <para>This only has an effect if a custom server certificate validation callback is being used ('ServerCertificateCustomValidationCallback' is set).</para>
// This implementation was mostly copied from https://github.com/dotnet/runtime/blob/0e3562e97c6db531f26a2ffe3e8084cf67ba8a93/src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.cs#L326-L335
/// <summary>Gets or sets the custom chain policy to use when validating certificate chains.</summary>
607
+
/// <remarks>
608
+
/// <para>The getter will never return a <see langword="null" /> policy, it will return a policy configured with the default behavior.</para>
609
+
/// <para>To select the default policy, call the setter with <see langword="null" /> value.</para>
610
+
/// <para>This only has an effect if a custom server certificate validation callback is being used ('ServerCertificateCustomValidationCallback' is set).</para>
611
+
/// </remarks>
612
+
publicX509ChainPolicy?CertificateChainPolicy{
613
+
get{
614
+
if(policyisnull){
615
+
policy=newX509ChainPolicy(){
616
+
RevocationMode=X509RevocationMode.Online,
617
+
RevocationFlag=X509RevocationFlag.ExcludeRoot,
618
+
// Ignore unknown revocation status, because Apple has a bug where revocation checks fail if the certificate(s)
619
+
// in question don't support revocation checking via OCSP.
// inspired by https://github.com/dotnet/runtime/blob/99d21b9276ebe8f7bea7fb3ba74dca9fca625fe2/src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/SignerInfo.cs#L691-L696
797
+
// See https://github.com/dotnet/macios/issues/23764 for more information.
0 commit comments