|
| 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 Preview 6 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 | +<xref:System.Net.Security.SslClientAuthenticationOptions.CertificateRevocationCheckMode?displayProperty=nameWithType> and <xref:System.Net.Security.SslServerAuthenticationOptions.CertificateRevocationCheckMode?displayProperty=nameWithType> default values 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 | +<xref:System.Net.Security.SslClientAuthenticationOptions.CertificateRevocationCheckMode?displayProperty=nameWithType> and <xref:System.Net.Security.SslServerAuthenticationOptions.CertificateRevocationCheckMode?displayProperty=nameWithType> default values were `NoCheck`, meaning certificate revocation lists weren't checked by default. |
| 20 | + |
| 21 | +```csharp |
| 22 | +var clientOptions = new SslClientAuthenticationOptions |
| 23 | +{ |
| 24 | + TargetHost = "example.com" |
| 25 | + // CertificateRevocationCheckMode defaults to NoCheck |
| 26 | +}; |
| 27 | + |
| 28 | +var serverOptions = new SslServerAuthenticationOptions |
| 29 | +{ |
| 30 | + ServerCertificate = serverCertificate |
| 31 | + // CertificateRevocationCheckMode defaults to NoCheck |
| 32 | +}; |
| 33 | +``` |
| 34 | + |
| 35 | +## New behavior |
| 36 | + |
| 37 | +<xref:System.Net.Security.SslClientAuthenticationOptions.CertificateRevocationCheckMode?displayProperty=nameWithType> and <xref:System.Net.Security.SslServerAuthenticationOptions.CertificateRevocationCheckMode?displayProperty=nameWithType> default values are `Online`, meaning certificate revocation lists are checked online by default. |
| 38 | + |
| 39 | +```csharp |
| 40 | +var clientOptions = new SslClientAuthenticationOptions |
| 41 | +{ |
| 42 | + TargetHost = "example.com" |
| 43 | + // CertificateRevocationCheckMode defaults to Online |
| 44 | +}; |
| 45 | + |
| 46 | +var serverOptions = new SslServerAuthenticationOptions |
| 47 | +{ |
| 48 | + ServerCertificate = serverCertificate |
| 49 | + // CertificateRevocationCheckMode defaults to Online |
| 50 | +}; |
| 51 | +``` |
| 52 | + |
| 53 | +## Type of breaking change |
| 54 | + |
| 55 | +This is a [behavioral change](../../categories.md#behavioral-change). |
| 56 | + |
| 57 | +## Reason for change |
| 58 | + |
| 59 | +This change enhances security and ensures consistency between APIs related to X.509 certificate revocation checking. |
| 60 | + |
| 61 | +## Recommended action |
| 62 | + |
| 63 | +If certificate revocation checking is not desired, specify `X509RevocationMode.NoCheck` explicitly: |
| 64 | + |
| 65 | +```csharp |
| 66 | +var clientOptions = new SslClientAuthenticationOptions |
| 67 | +{ |
| 68 | + TargetHost = "example.com", |
| 69 | + CertificateRevocationCheckMode = X509RevocationMode.NoCheck |
| 70 | +}; |
| 71 | + |
| 72 | +var serverOptions = new SslServerAuthenticationOptions |
| 73 | +{ |
| 74 | + ServerCertificate = serverCertificate, |
| 75 | + CertificateRevocationCheckMode = X509RevocationMode.NoCheck |
| 76 | +}; |
| 77 | +``` |
| 78 | + |
| 79 | +In situations where the code might not be modified, previous behavior can be enabled by setting either: |
| 80 | + |
| 81 | +- `System.Net.Security.NoRevocationCheckByDefault` AppContext switch to `true` |
| 82 | +- `DOTNET_SYSTEM_NET_SECURITY_NOREVOCATIONCHECKBYDEFAULT` environment variable to `true` |
| 83 | + |
| 84 | +## Affected APIs |
| 85 | + |
| 86 | +- <xref:System.Net.Security.SslStream.AuthenticateAsClient%2A?displayProperty=fullName> |
| 87 | +- <xref:System.Net.Security.SslStream.AuthenticateAsClientAsync%2A?displayProperty=fullName> |
| 88 | +- <xref:System.Net.Security.SslStream.AuthenticateAsServer%2A?displayProperty=fullName> |
| 89 | +- <xref:System.Net.Security.SslStream.AuthenticateAsServerAsync%2A?displayProperty=fullName> |
| 90 | +- <xref:System.Net.Http.HttpClient?displayProperty=fullName> |
0 commit comments