|
| 1 | +--- |
| 2 | +title: "Breaking change - HttpClient/SslStream default certificate revocation check mode changed to Online" |
| 3 | +description: "Learn about the breaking change in .NET 10 where the default certificate revocation check mode changed from 'NoCheck' to 'Online'." |
| 4 | +ms.date: 06/23/2025 |
| 5 | +ai-usage: ai-assisted |
| 6 | +ms.custom: https://github.com/dotnet/docs/issues/46824 |
| 7 | +--- |
| 8 | + |
| 9 | +# HttpClient/SslStream default certificate revocation check mode changed to `Online` |
| 10 | + |
| 11 | +The default values of <xref:System.Net.Security.SslClientAuthenticationOptions.CertificateRevocationCheckMode?displayProperty=nameWithType> and <xref:System.Net.Security.SslServerAuthenticationOptions.CertificateRevocationCheckMode?displayProperty=nameWithType> have changed from `NoCheck` to `Online`. This change enhances security and makes the behavior consistent with <xref:System.Security.Cryptography.X509Certificates.X509ChainPolicy?displayProperty=nameWithType>. |
| 12 | + |
| 13 | +## Version introduced |
| 14 | + |
| 15 | +.NET 10 Preview 6 |
| 16 | + |
| 17 | +## Previous behavior |
| 18 | + |
| 19 | +Previously, the default values of <xref:System.Net.Security.SslClientAuthenticationOptions.CertificateRevocationCheckMode?displayProperty=nameWithType> and <xref:System.Net.Security.SslServerAuthenticationOptions.CertificateRevocationCheckMode?displayProperty=nameWithType> were <xref:System.Security.Cryptography.X509Certificates.X509RevocationMode.NoCheck?displayProperty=nameWithType>, meaning revocation status of peer certificates wasn't checked by default. |
| 20 | + |
| 21 | +## New behavior |
| 22 | + |
| 23 | +Starting in .NET 10, the default values of <xref:System.Net.Security.SslClientAuthenticationOptions.CertificateRevocationCheckMode?displayProperty=nameWithType> and <xref:System.Net.Security.SslServerAuthenticationOptions.CertificateRevocationCheckMode?displayProperty=nameWithType> are <xref:System.Security.Cryptography.X509Certificates.X509RevocationMode.Online?displayProperty=nameWithType>, meaning revocation status of peer certificates are checked online by default. |
| 24 | + |
| 25 | +## Type of breaking change |
| 26 | + |
| 27 | +This change is a [behavioral change](../../categories.md#behavioral-change). |
| 28 | + |
| 29 | +## Reason for change |
| 30 | + |
| 31 | +This change enhances security and ensures consistency between APIs related to X.509 certificate revocation checking. |
| 32 | + |
| 33 | +## Recommended action |
| 34 | + |
| 35 | +If certificate revocation checking is not desired, specify <xref:System.Security.Cryptography.X509Certificates.X509RevocationMode.NoCheck?displayProperty=nameWithType> explicitly: |
| 36 | + |
| 37 | +```csharp |
| 38 | +var clientOptions = new SslClientAuthenticationOptions |
| 39 | +{ |
| 40 | + TargetHost = "example.com", |
| 41 | + CertificateRevocationCheckMode = X509RevocationMode.NoCheck |
| 42 | +}; |
| 43 | + |
| 44 | +var serverOptions = new SslServerAuthenticationOptions |
| 45 | +{ |
| 46 | + ServerCertificate = serverCertificate, |
| 47 | + CertificateRevocationCheckMode = X509RevocationMode.NoCheck |
| 48 | +}; |
| 49 | +``` |
| 50 | + |
| 51 | +> [!NOTE] |
| 52 | +> Due to a bug on the OSX platform, you might encounter certificate validation failures with <xref:System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.RevocationStatusUnknown?displayProperty=nameWithType> in scenarios where the certificate doesn't support revocation checking via OCSP. This is a bug in the underlying platform crypto implementation. To avoid failing the certificate validation if revocation status can't be retrieved, either disable certificate revocation checking as per the previous instructions, or set <xref:System.Security.Cryptography.X509Certificates.X509ChainPolicy> with <xref:System.Security.Cryptography.X509Certificates.X509ChainPolicy.VerificationFlags?displayProperty=nameWithType> set to `X509VerificationFlags.IgnoreEndRevocationUnknown | X509VerificationFlags.IgnoreCertificateAuthorityRevocationUnknown`. |
| 53 | +
|
| 54 | +In situations where you can't modify the code, you can restore the previous behavior with one of the following settings: |
| 55 | + |
| 56 | +- Set `System.Net.Security.NoRevocationCheckByDefault` AppContext switch to `true`. |
| 57 | +- Set `DOTNET_SYSTEM_NET_SECURITY_NOREVOCATIONCHECKBYDEFAULT` environment variable to `true`. |
| 58 | + |
| 59 | +## Affected APIs |
| 60 | + |
| 61 | +- <xref:System.Net.Security.SslStream.AuthenticateAsClient%2A?displayProperty=fullName> |
| 62 | +- <xref:System.Net.Security.SslStream.AuthenticateAsClientAsync%2A?displayProperty=fullName> |
| 63 | +- <xref:System.Net.Security.SslStream.AuthenticateAsServer%2A?displayProperty=fullName> |
| 64 | +- <xref:System.Net.Security.SslStream.AuthenticateAsServerAsync%2A?displayProperty=fullName> |
| 65 | +- <xref:System.Net.Http.HttpClient.Send*?displayProperty=fullName> (when using either <xref:System.Net.Http.WinHttpHandler> or <xref:System.Net.Http.SocketsHttpHandler>) |
| 66 | +- <xref:System.Net.Http.HttpClient.SendAsync*?displayProperty=fullName> (when using either <xref:System.Net.Http.WinHttpHandler> or <xref:System.Net.Http.SocketsHttpHandler>) |
0 commit comments