Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
439487a
Merged PR 32920: limit AIA download size
Aug 15, 2023
4f9fac6
Merge in 'release/8.0-rc1' changes
dotnet-bot Aug 15, 2023
cfde4d6
Merge in 'release/8.0-rc1' changes
dotnet-bot Aug 15, 2023
efdbbfe
Merge in 'release/8.0-rc1' changes
dotnet-bot Aug 16, 2023
ea12d7f
Merge in 'release/8.0-rc1' changes
dotnet-bot Aug 16, 2023
21ff7c6
Merge in 'release/8.0-rc1' changes
dotnet-bot Aug 16, 2023
0d60034
Merge in 'release/8.0-rc1' changes
dotnet-bot Aug 16, 2023
7f79bc4
Merge in 'release/8.0-rc1' changes
dotnet-bot Aug 16, 2023
543e733
Update Microsoft.DiaSymReader.Native to 16.11.29-beta1.23404.4
hoyosjs Aug 16, 2023
ccf278f
Merge in 'release/8.0-rc1' changes
dotnet-bot Aug 16, 2023
78fa179
Merge in 'release/8.0-rc1' changes
dotnet-bot Aug 16, 2023
7e4c8f6
Merge in 'release/8.0-rc1' changes
dotnet-bot Aug 16, 2023
625685b
Merge in 'release/8.0-rc1' changes
dotnet-bot Aug 16, 2023
0be0088
Merge in 'release/8.0-rc1' changes
dotnet-bot Aug 16, 2023
e0c5c1c
Merge in 'release/8.0-rc1' changes
dotnet-bot Aug 16, 2023
f65f931
Merge in 'release/8.0-rc1' changes
dotnet-bot Aug 16, 2023
11d2959
Merge in 'release/8.0-rc1' changes
dotnet-bot Aug 17, 2023
52f2403
Merge in 'release/8.0-rc1' changes
dotnet-bot Aug 17, 2023
420dd6d
Merge in 'release/8.0-rc1' changes
dotnet-bot Aug 17, 2023
04ff472
Merge in 'release/8.0-rc1' changes
dotnet-bot Aug 17, 2023
397eb66
Merge in 'release/8.0-rc1' changes
dotnet-bot Aug 18, 2023
375fdc2
Merge in 'release/8.0-rc1' changes
dotnet-bot Aug 18, 2023
13854cd
Merge in 'release/8.0-rc1' changes
dotnet-bot Aug 18, 2023
df0cc13
Merge in 'release/8.0-rc1' changes
dotnet-bot Aug 19, 2023
4bdeb72
Merge in 'release/8.0-rc1' changes
dotnet-bot Aug 19, 2023
9295993
Merge in 'release/8.0-rc1' changes
dotnet-bot Aug 19, 2023
f18363c
Merge commit '92959931a32a37a19d8e1b1684edc6db0857d7de' into internal…
vseanreesermsft Sep 12, 2023
ac80397
Merge branch 'release/8.0' into internal-merge-8.0-2023-09-12-1259
carlossanlop Sep 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
<optimizationlinuxarm64MIBCRuntimeVersion>1.0.0-prerelease.23458.2</optimizationlinuxarm64MIBCRuntimeVersion>
<optimizationPGOCoreCLRVersion>1.0.0-prerelease.23458.2</optimizationPGOCoreCLRVersion>
<!-- Not auto-updated. -->
<MicrosoftDiaSymReaderNativeVersion>16.11.27-beta1.23180.1</MicrosoftDiaSymReaderNativeVersion>
<MicrosoftDiaSymReaderNativeVersion>16.11.29-beta1.23404.4</MicrosoftDiaSymReaderNativeVersion>
<SystemCommandLineVersion>2.0.0-beta4.23307.1</SystemCommandLineVersion>
<TraceEventVersion>3.0.3</TraceEventVersion>
<NETStandardLibraryRefVersion>2.1.0</NETStandardLibraryRefVersion>
Expand Down
26 changes: 25 additions & 1 deletion src/libraries/Common/src/System/Net/Http/X509ResourceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ namespace System.Net.Http
{
internal static partial class X509ResourceClient
{
private const long DefaultAiaDownloadLimit = 100 * 1024 * 1024;
private static long AiaDownloadLimit { get; } = GetValue("System.Security.Cryptography.AiaDownloadLimit", DefaultAiaDownloadLimit);

private static readonly Func<string, CancellationToken, bool, Task<byte[]?>>? s_downloadBytes = CreateDownloadBytesFunc();

static partial void ReportNoClient();
Expand Down Expand Up @@ -111,6 +114,7 @@ internal static partial class X509ResourceClient
ConstructorInfo? httpRequestMessageCtor = httpRequestMessageType.GetConstructor(Type.EmptyTypes);
MethodInfo? sendMethod = httpClientType.GetMethod("Send", new Type[] { httpRequestMessageType, typeof(CancellationToken) });
MethodInfo? sendAsyncMethod = httpClientType.GetMethod("SendAsync", new Type[] { httpRequestMessageType, typeof(CancellationToken) });
PropertyInfo? maxResponseContentBufferSizeProp = httpClientType.GetProperty("MaxResponseContentBufferSize");
PropertyInfo? responseContentProp = httpResponseMessageType.GetProperty("Content");
PropertyInfo? responseStatusCodeProp = httpResponseMessageType.GetProperty("StatusCode");
PropertyInfo? responseHeadersProp = httpResponseMessageType.GetProperty("Headers");
Expand All @@ -121,7 +125,7 @@ internal static partial class X509ResourceClient
if (socketsHttpHandlerCtor == null || pooledConnectionIdleTimeoutProp == null ||
allowAutoRedirectProp == null || httpClientCtor == null ||
requestUriProp == null || httpRequestMessageCtor == null ||
sendMethod == null || sendAsyncMethod == null ||
sendMethod == null || sendAsyncMethod == null || maxResponseContentBufferSizeProp == null ||
responseContentProp == null || responseStatusCodeProp == null ||
responseHeadersProp == null || responseHeadersLocationProp == null ||
readAsStreamMethod == null || taskOfHttpResponseMessageResultProp == null)
Expand All @@ -145,6 +149,7 @@ internal static partial class X509ResourceClient
pooledConnectionIdleTimeoutProp.SetValue(socketsHttpHandler, TimeSpan.FromSeconds(PooledConnectionIdleTimeoutSeconds));
allowAutoRedirectProp.SetValue(socketsHttpHandler, false);
object? httpClient = httpClientCtor.Invoke(new object?[] { socketsHttpHandler });
maxResponseContentBufferSizeProp.SetValue(httpClient, AiaDownloadLimit);

return async (string uriString, CancellationToken cancellationToken, bool async) =>
{
Expand Down Expand Up @@ -302,5 +307,24 @@ private static bool IsAllowedScheme(string scheme)
{
return string.Equals(scheme, "http", StringComparison.OrdinalIgnoreCase);
}

private static long GetValue(string name, long defaultValue)
{
object? data = AppContext.GetData(name);

if (data is null)
{
return defaultValue;
}

try
{
return Convert.ToInt64(data);
}
catch
{
return defaultValue;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Linq;
using System.Security.Cryptography.X509Certificates.Tests.Common;
using Microsoft.DotNet.RemoteExecutor;
using Test.Cryptography;
using Xunit;

Expand Down Expand Up @@ -178,5 +179,44 @@ public static void DisableAiaOptionWorks()
});
}
}

[ActiveIssue("https://github.com/dotnet/runtime/issues/57506", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoRuntime), nameof(PlatformDetection.IsMariner))]
[PlatformSpecific(TestPlatforms.Linux)]
[ConditionalFact(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
public static void AiaIgnoresCertOverLimit()
{
RemoteExecutor.Invoke(() =>
{
AppContext.SetData("System.Security.Cryptography.AiaDownloadLimit", 100);
CertificateAuthority.BuildPrivatePki(
PkiOptions.AllRevocation,
out RevocationResponder responder,
out CertificateAuthority root,
out CertificateAuthority intermediate,
out X509Certificate2 endEntity,
pkiOptionsInSubject: false,
testName: Guid.NewGuid().ToString());

using (responder)
using (root)
using (intermediate)
using (endEntity)
using (X509Certificate2 rootCert = root.CloneIssuerCert())
{
responder.AiaResponseKind = AiaResponseKind.Cert;

using (ChainHolder holder = new ChainHolder())
{
X509Chain chain = holder.Chain;
chain.ChainPolicy.CustomTrustStore.Add(rootCert);
chain.ChainPolicy.TrustMode = X509ChainTrustMode.CustomRootTrust;
chain.ChainPolicy.VerificationTime = endEntity.NotBefore.AddMinutes(1);
chain.ChainPolicy.UrlRetrievalTimeout = DynamicRevocationTests.s_urlRetrievalLimit;

Assert.False(chain.Build(endEntity));
}
}
}).Dispose();
}
}
}