Skip to content

Commit

Permalink
Merge pull request #91917 from dotnet-maestro-bot/merge/release/6.0-t…
Browse files Browse the repository at this point in the history
…o-release/6.0-staging

[automated] Merge branch 'release/6.0' => 'release/6.0-staging'
  • Loading branch information
carlossanlop authored Sep 19, 2023
2 parents c2f1e7e + 5e1c5bb commit 27746ce
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
<optimizationlinuxx64MIBCRuntimeVersion>1.0.0-prerelease.21416.5</optimizationlinuxx64MIBCRuntimeVersion>
<optimizationPGOCoreCLRVersion>1.0.0-prerelease.21416.5</optimizationPGOCoreCLRVersion>
<!-- Not auto-updated. -->
<MicrosoftDiaSymReaderNativeVersion>16.11.27-beta1.23180.1</MicrosoftDiaSymReaderNativeVersion>
<MicrosoftDiaSymReaderNativeVersion>16.11.29-beta1.23404.4</MicrosoftDiaSymReaderNativeVersion>
<SystemCommandLineVersion>2.0.0-beta1.20253.1</SystemCommandLineVersion>
<TraceEventVersion>2.0.65</TraceEventVersion>
<CommandLineParserVersion>2.2.0</CommandLineParserVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ private MsQuicApi(NativeApi* vtable)
#pragma warning disable CA1810 // Initialize all static fields in 'MsQuicApi' when those fields are declared and remove the explicit static constructor
static MsQuicApi()
{
// Completely disabled QUIC.
IsQuicSupported = false;
if (NetEventSource.Log.IsEnabled())
{
NetEventSource.Info(null, $"QUIC is completely disabled in .NET 6 due to critical defects fixed in later versions.");
}
return;

#pragma warning disable CS0162 // Unreachable code detected -- leaving the original code intact, instead of removing big chunks of code transitively
if (OperatingSystem.IsWindows() && !IsWindowsVersionSupported())
{
if (NetEventSource.Log.IsEnabled())
Expand Down Expand Up @@ -163,7 +172,7 @@ static MsQuicApi()
// Gracefully close the API table to free resources. The API table will be allocated lazily again if needed
MsQuicClose(apiTable);
}
#pragma warning restore CA1810
#pragma warning restore CA1810, CS0162

private static MsQuicApi AllocateMsQuicApi()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ namespace Internal.Cryptography.Pal
{
internal static class CertificateAssetDownloader
{
private const long DefaultAiaDownloadLimit = 100 * 1024 * 1024;

private static long AiaDownloadLimit { get; } = GetValue("System.Security.Cryptography.AiaDownloadLimit", DefaultAiaDownloadLimit);
private static readonly Func<string, CancellationToken, byte[]?>? s_downloadBytes = CreateDownloadBytesFunc();

internal static X509Certificate2? DownloadCertificate(string uri, TimeSpan downloadTimeout)
Expand Down Expand Up @@ -161,6 +164,7 @@ internal static class CertificateAssetDownloader
PropertyInfo? requestUriProp = httpRequestMessageType.GetProperty("RequestUri");
ConstructorInfo? httpRequestMessageCtor = httpRequestMessageType.GetConstructor(Type.EmptyTypes);
MethodInfo? sendMethod = httpClientType.GetMethod("Send", 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 @@ -169,7 +173,7 @@ internal static class CertificateAssetDownloader

if (socketsHttpHandlerCtor == null || pooledConnectionIdleTimeoutProp == null || allowAutoRedirectProp == null || httpClientCtor == null ||
requestUriProp == null || httpRequestMessageCtor == null || sendMethod == null || responseContentProp == null || responseStatusCodeProp == null ||
responseHeadersProp == null || responseHeadersLocationProp == null || readAsStreamMethod == null)
responseHeadersProp == null || responseHeadersLocationProp == null || readAsStreamMethod == null || maxResponseContentBufferSizeProp == null)
{
Debug.Fail("Unable to load required member.");
return null;
Expand All @@ -190,6 +194,7 @@ internal static class CertificateAssetDownloader
pooledConnectionIdleTimeoutProp.SetValue(socketsHttpHandler, TimeSpan.FromSeconds(PooledConnectionIdleTimeoutSeconds));
allowAutoRedirectProp.SetValue(socketsHttpHandler, false);
object? httpClient = httpClientCtor.Invoke(new object?[] { socketsHttpHandler });
maxResponseContentBufferSizeProp.SetValue(httpClient, AiaDownloadLimit);

return (string uriString, CancellationToken cancellationToken) =>
{
Expand Down Expand Up @@ -313,5 +318,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;
}
}
}
}

0 comments on commit 27746ce

Please sign in to comment.