Skip to content

Commit 36e33db

Browse files
authored
Merge pull request #91916 from dotnet-maestro-bot/merge/release/7.0-to-release/7.0-staging
[automated] Merge branch 'release/7.0' => 'release/7.0-staging'
2 parents c7425f7 + feffbcc commit 36e33db

File tree

4 files changed

+68
-4
lines changed

4 files changed

+68
-4
lines changed

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
<optimizationlinuxarm64MIBCRuntimeVersion>1.0.0-prerelease.22415.6</optimizationlinuxarm64MIBCRuntimeVersion>
141141
<optimizationPGOCoreCLRVersion>1.0.0-prerelease.22415.6</optimizationPGOCoreCLRVersion>
142142
<!-- Not auto-updated. -->
143-
<MicrosoftDiaSymReaderNativeVersion>16.11.27-beta1.23180.1</MicrosoftDiaSymReaderNativeVersion>
143+
<MicrosoftDiaSymReaderNativeVersion>16.11.29-beta1.23404.4</MicrosoftDiaSymReaderNativeVersion>
144144
<SystemCommandLineVersion>2.0.0-beta4.22355.1</SystemCommandLineVersion>
145145
<TraceEventVersion>3.0.3</TraceEventVersion>
146146
<NETStandardLibraryRefVersion>2.1.0</NETStandardLibraryRefVersion>

src/libraries/Common/src/System/Net/Http/X509ResourceClient.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ namespace System.Net.Http
1212
{
1313
internal static partial class X509ResourceClient
1414
{
15+
private const long DefaultAiaDownloadLimit = 100 * 1024 * 1024;
16+
17+
private static long AiaDownloadLimit { get; } = GetValue("System.Security.Cryptography.AiaDownloadLimit", DefaultAiaDownloadLimit);
1518
private static readonly Func<string, CancellationToken, bool, ValueTask<byte[]?>>? s_downloadBytes = CreateDownloadBytesFunc();
1619

1720
static partial void ReportNoClient();
@@ -115,6 +118,7 @@ internal static partial class X509ResourceClient
115118
ConstructorInfo? httpRequestMessageCtor = httpRequestMessageType.GetConstructor(Type.EmptyTypes);
116119
MethodInfo? sendMethod = httpClientType.GetMethod("Send", new Type[] { httpRequestMessageType, typeof(CancellationToken) });
117120
MethodInfo? sendAsyncMethod = httpClientType.GetMethod("SendAsync", new Type[] { httpRequestMessageType, typeof(CancellationToken) });
121+
PropertyInfo? maxResponseContentBufferSizeProp = httpClientType.GetProperty("MaxResponseContentBufferSize");
118122
PropertyInfo? responseContentProp = httpResponseMessageType.GetProperty("Content");
119123
PropertyInfo? responseStatusCodeProp = httpResponseMessageType.GetProperty("StatusCode");
120124
PropertyInfo? responseHeadersProp = httpResponseMessageType.GetProperty("Headers");
@@ -125,7 +129,7 @@ internal static partial class X509ResourceClient
125129
if (socketsHttpHandlerCtor == null || pooledConnectionIdleTimeoutProp == null ||
126130
allowAutoRedirectProp == null || httpClientCtor == null ||
127131
requestUriProp == null || httpRequestMessageCtor == null ||
128-
sendMethod == null || sendAsyncMethod == null ||
132+
sendMethod == null || sendAsyncMethod == null || maxResponseContentBufferSizeProp == null ||
129133
responseContentProp == null || responseStatusCodeProp == null ||
130134
responseHeadersProp == null || responseHeadersLocationProp == null ||
131135
readAsStreamMethod == null || taskOfHttpResponseMessageResultProp == null)
@@ -149,6 +153,7 @@ internal static partial class X509ResourceClient
149153
pooledConnectionIdleTimeoutProp.SetValue(socketsHttpHandler, TimeSpan.FromSeconds(PooledConnectionIdleTimeoutSeconds));
150154
allowAutoRedirectProp.SetValue(socketsHttpHandler, false);
151155
object? httpClient = httpClientCtor.Invoke(new object?[] { socketsHttpHandler });
156+
maxResponseContentBufferSizeProp.SetValue(httpClient, AiaDownloadLimit);
152157

153158
return async (string uriString, CancellationToken cancellationToken, bool async) =>
154159
{
@@ -306,5 +311,24 @@ private static bool IsAllowedScheme(string scheme)
306311
{
307312
return string.Equals(scheme, "http", StringComparison.OrdinalIgnoreCase);
308313
}
314+
315+
private static long GetValue(string name, long defaultValue)
316+
{
317+
object? data = AppContext.GetData(name);
318+
319+
if (data is null)
320+
{
321+
return defaultValue;
322+
}
323+
324+
try
325+
{
326+
return Convert.ToInt64(data);
327+
}
328+
catch
329+
{
330+
return defaultValue;
331+
}
332+
}
309333
}
310334
}

src/libraries/Microsoft.Windows.Compatibility/src/Microsoft.Windows.Compatibility.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<!-- Reference the outputs for the dependency nodes calculation. -->
66
<NoTargetsDoNotReferenceOutputAssemblies>false</NoTargetsDoNotReferenceOutputAssemblies>
77
<IsPackable>true</IsPackable>
8-
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
9-
<ServicingVersion>4</ServicingVersion>
8+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
9+
<ServicingVersion>5</ServicingVersion>
1010
<!-- This is a meta package and doesn't contain any libs. -->
1111
<NoWarn>$(NoWarn);NU5128</NoWarn>
1212
<PackageDescription>This Windows Compatibility Pack provides access to APIs that were previously available only for .NET Framework. It can be used from both .NET as well as .NET Standard.</PackageDescription>

src/libraries/System.Security.Cryptography.X509Certificates/tests/RevocationTests/AiaTests.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System.Linq;
55
using System.Security.Cryptography.X509Certificates.Tests.Common;
6+
using Microsoft.DotNet.RemoteExecutor;
67
using Test.Cryptography;
78
using Xunit;
89

@@ -177,5 +178,44 @@ public static void DisableAiaOptionWorks()
177178
});
178179
}
179180
}
181+
182+
[ActiveIssue("https://github.com/dotnet/runtime/issues/57506", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsMariner))]
183+
[PlatformSpecific(TestPlatforms.Linux)]
184+
[ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
185+
public static void AiaIgnoresCertOverLimit()
186+
{
187+
RemoteExecutor.Invoke(() =>
188+
{
189+
AppContext.SetData("System.Security.Cryptography.AiaDownloadLimit", 100);
190+
CertificateAuthority.BuildPrivatePki(
191+
PkiOptions.AllRevocation,
192+
out RevocationResponder responder,
193+
out CertificateAuthority root,
194+
out CertificateAuthority intermediate,
195+
out X509Certificate2 endEntity,
196+
pkiOptionsInSubject: false,
197+
testName: Guid.NewGuid().ToString());
198+
199+
using (responder)
200+
using (root)
201+
using (intermediate)
202+
using (endEntity)
203+
using (X509Certificate2 rootCert = root.CloneIssuerCert())
204+
{
205+
responder.AiaResponseKind = AiaResponseKind.Cert;
206+
207+
using (ChainHolder holder = new ChainHolder())
208+
{
209+
X509Chain chain = holder.Chain;
210+
chain.ChainPolicy.CustomTrustStore.Add(rootCert);
211+
chain.ChainPolicy.TrustMode = X509ChainTrustMode.CustomRootTrust;
212+
chain.ChainPolicy.VerificationTime = endEntity.NotBefore.AddMinutes(1);
213+
chain.ChainPolicy.UrlRetrievalTimeout = DynamicRevocationTests.s_urlRetrievalLimit;
214+
215+
Assert.False(chain.Build(endEntity));
216+
}
217+
}
218+
}).Dispose();
219+
}
180220
}
181221
}

0 commit comments

Comments
 (0)