You've already forked linux-packaging-mono
Imported Upstream version 4.8.0.309
Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
parent
ee1447783b
commit
94b2861243
@@ -3,6 +3,15 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// ==--==
|
||||
|
||||
// There are cases where we have multiple assemblies that are going to import this file and
|
||||
// if they are going to also have InternalsVisibleTo between them, there will be a compiler warning
|
||||
// that the type is found both in the source and in a referenced assembly. The compiler will prefer
|
||||
// the version of the type defined in the source
|
||||
//
|
||||
// In order to disable the warning for this type we are disabling this warning for this entire file.
|
||||
#pragma warning disable 436
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -167,3 +176,5 @@ namespace System
|
||||
static partial void PopulateDefaultValuesPartial(string platformIdentifier, string profile, int version);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning restore 436
|
||||
|
||||
@@ -4,6 +4,14 @@
|
||||
//
|
||||
// ==--==
|
||||
|
||||
// There are cases where we have multiple assemblies that are going to import this file and
|
||||
// if they are going to also have InternalsVisibleTo between them, there will be a compiler warning
|
||||
// that the type is found both in the source and in a referenced assembly. The compiler will prefer
|
||||
// the version of the type defined in the source
|
||||
//
|
||||
// In order to disable the warning for this type we are disabling this warning for this entire file.
|
||||
#pragma warning disable 436
|
||||
|
||||
// NOTE: This file should not be included in mscorlib. This should only be included in FX libraries that need to provide switches
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -126,3 +134,5 @@ namespace System
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning restore 436
|
||||
|
||||
@@ -155,7 +155,14 @@ namespace System
|
||||
if (PinnableBufferCacheEventSource.Log.IsEnabled())
|
||||
PinnableBufferCacheEventSource.Log.FreeBuffer(m_CacheName, PinnableBufferCacheEventSource.AddressOf(buffer), buffer.GetHashCode(), m_FreeList.Count);
|
||||
|
||||
|
||||
if(buffer == null)
|
||||
{
|
||||
if (PinnableBufferCacheEventSource.Log.IsEnabled())
|
||||
PinnableBufferCacheEventSource.Log.FreeBufferNull(m_CacheName, m_FreeList.Count);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// After we've done 3 gen1 GCs, assume that all buffers have aged into gen2 on the free path.
|
||||
if ((m_gen1CountAtLastRestock + 3) > GC.CollectionCount(GC.MaxGeneration - 1))
|
||||
{
|
||||
@@ -567,6 +574,7 @@ namespace System
|
||||
public void AllocateBufferAged(string cacheName, int agedCount) {}
|
||||
public void AllocateBufferFreeListEmpty(string cacheName, int notGen2CountBefore) {}
|
||||
public void FreeBuffer(string cacheName, ulong objectId, int objectHash, int freeCountBefore) {}
|
||||
public void FreeBufferNull(string cacheName, int freeCountBefore) { }
|
||||
public void FreeBufferStillTooYoung(string cacheName, int notGen2CountBefore) {}
|
||||
public void TrimCheck(string cacheName, int totalBuffs, bool neededMoreThanFreeList, int deltaMSec) {}
|
||||
public void TrimFree(string cacheName, int totalBuffs, int freeListCount, int toBeFreed) {}
|
||||
@@ -643,6 +651,8 @@ namespace System
|
||||
public void AgePendingBuffersResults(string cacheName, int promotedToFreeListCount, int heldBackCount) { if (IsEnabled()) WriteEvent(20, cacheName, promotedToFreeListCount, heldBackCount); }
|
||||
[Event(21)]
|
||||
public void WalkFreeListResult(string cacheName, int freeListCount, int gen0BuffersInFreeList) { if (IsEnabled()) WriteEvent(21, cacheName, freeListCount, gen0BuffersInFreeList); }
|
||||
[Event(22)]
|
||||
public void FreeBufferNull(string cacheName, int freeCountBefore) { if(IsEnabled()) WriteEvent(22, cacheName, freeCountBefore); }
|
||||
|
||||
|
||||
static internal ulong AddressOf(object obj)
|
||||
|
||||
@@ -169,6 +169,23 @@ namespace Microsoft.Win32 {
|
||||
[ResourceExposure(ResourceScope.None)]
|
||||
public static extern bool WTSUnRegisterSessionNotification(HandleRef hWnd);
|
||||
|
||||
private static IntPtr GetCurrentProcessToken() { return new IntPtr(-4); }
|
||||
|
||||
private const int ERROR_SUCCESS = 0;
|
||||
|
||||
enum AppPolicyClrCompat
|
||||
{
|
||||
AppPolicyClrCompat_Others = 0,
|
||||
AppPolicyClrCompat_ClassicDesktop = 1,
|
||||
AppPolicyClrCompat_Universal = 2,
|
||||
AppPolicyClrCompat_PackagedDesktop = 3
|
||||
};
|
||||
|
||||
[DllImport(ExternDll.Kernel32, CharSet = CharSet.None, EntryPoint = "AppPolicyGetClrCompat")]
|
||||
[System.Security.SecuritySafeCritical]
|
||||
[return: MarshalAs(UnmanagedType.I4)]
|
||||
private static extern Int32 _AppPolicyGetClrCompat(IntPtr processToken, out AppPolicyClrCompat appPolicyClrCompat);
|
||||
|
||||
private const int ERROR_INSUFFICIENT_BUFFER = 0x007A;
|
||||
private const int ERROR_NO_PACKAGE_IDENTITY = 0x3d54;
|
||||
|
||||
@@ -204,8 +221,20 @@ namespace Microsoft.Win32 {
|
||||
[System.Security.SecuritySafeCritical]
|
||||
private static bool _IsPackagedProcess()
|
||||
{
|
||||
Version windows8Version = new Version(6, 2, 0, 0);
|
||||
OperatingSystem os = Environment.OSVersion;
|
||||
if(os.Platform == PlatformID.Win32NT && os.Version >= new Version(6,2,0,0) && DoesWin32MethodExist(ExternDll.Kernel32, "GetCurrentPackageId"))
|
||||
bool osSupportsPackagedProcesses = os.Platform == PlatformID.Win32NT && os.Version >= windows8Version;
|
||||
|
||||
if (osSupportsPackagedProcesses && DoesWin32MethodExist(ExternDll.Kernel32, "AppPolicyGetClrCompat"))
|
||||
{
|
||||
// Use AppPolicyGetClrCompat if it is available. Return true if and only if this is a UWA which means if
|
||||
// this is packaged desktop app this method will return false. This may cause some confusion however
|
||||
// this is necessary to make the behavior of packaged desktop apps identical to desktop apps.
|
||||
AppPolicyClrCompat appPolicyClrCompat;
|
||||
return _AppPolicyGetClrCompat(GetCurrentProcessToken(), out appPolicyClrCompat) == ERROR_SUCCESS &&
|
||||
appPolicyClrCompat == AppPolicyClrCompat.AppPolicyClrCompat_Universal;
|
||||
}
|
||||
else if(osSupportsPackagedProcesses && DoesWin32MethodExist(ExternDll.Kernel32, "GetCurrentPackageId"))
|
||||
{
|
||||
Int32 bufLen = 0;
|
||||
// Will return ERROR_INSUFFICIENT_BUFFER when running within a packaged application,
|
||||
|
||||
@@ -326,9 +326,19 @@ namespace System.ComponentModel {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((mdObj.description == null) != (description == null) ||
|
||||
(description != null && !mdObj.category.Equals(description))) {
|
||||
return false;
|
||||
// VSO 149471 - Technically fixing this could cause a behavior change, so we are
|
||||
// adding a quirk in case anyone is bit by this and needs the old, buggy behavior.
|
||||
if (!LocalAppContextSwitches.MemberDescriptorEqualsReturnsFalseIfEquivalent) {
|
||||
if ((mdObj.description == null) != (description == null) ||
|
||||
(description != null && !mdObj.description.Equals(description))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((mdObj.description == null) != (description == null) ||
|
||||
(description != null && !mdObj.category.Equals(description))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ((mdObj.attributes == null) != (attributes == null)) {
|
||||
|
||||
@@ -101,11 +101,15 @@ using System.Configuration;
|
||||
{
|
||||
if (s_CacheConfigSettings == null)
|
||||
{
|
||||
#if MONO
|
||||
var settings = new RequestCachingSectionInternal();
|
||||
#else
|
||||
RequestCachingSectionInternal settings = RequestCachingSectionInternal.GetSection();
|
||||
|
||||
s_DefaultGlobalBinding = new RequestCacheBinding (settings.DefaultCache, settings.DefaultHttpValidator, settings.DefaultCachePolicy);
|
||||
s_DefaultHttpBinding = new RequestCacheBinding (settings.DefaultCache, settings.DefaultHttpValidator, settings.DefaultHttpCachePolicy);
|
||||
s_DefaultFtpBinding = new RequestCacheBinding (settings.DefaultCache, settings.DefaultFtpValidator, settings.DefaultFtpCachePolicy);
|
||||
#endif
|
||||
|
||||
s_CacheConfigSettings = settings;
|
||||
}
|
||||
@@ -113,6 +117,22 @@ using System.Configuration;
|
||||
}
|
||||
}
|
||||
|
||||
#if MONO
|
||||
class RequestCacheValidator
|
||||
{
|
||||
public object CreateValidator ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
class RequestCachingSectionInternal
|
||||
{
|
||||
// TODO: Implement
|
||||
public readonly bool DisableAllCaching = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
//
|
||||
internal class RequestCacheBinding {
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace System.Net.Configuration
|
||||
using System.Security.Principal;
|
||||
using System.ComponentModel;
|
||||
|
||||
|
||||
#if !MONO
|
||||
public sealed class DefaultProxySection : ConfigurationSection
|
||||
{
|
||||
public DefaultProxySection()
|
||||
@@ -134,9 +134,10 @@ namespace System.Net.Configuration
|
||||
base.Reset(defaultElement);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
internal sealed class DefaultProxySectionInternal
|
||||
{
|
||||
#if !MONO
|
||||
[SecurityPermission(SecurityAction.Assert, Flags=SecurityPermissionFlag.ControlPrincipal)]
|
||||
internal DefaultProxySectionInternal(DefaultProxySection section)
|
||||
{
|
||||
@@ -274,6 +275,50 @@ namespace System.Net.Configuration
|
||||
this.webProxy.Credentials = SystemNetworkCredential.defaultCredential;
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
static IWebProxy GetDefaultProxy_UsingOldMonoCode()
|
||||
{
|
||||
#if CONFIGURATION_DEP
|
||||
DefaultProxySection sec = ConfigurationManager.GetSection ("system.net/defaultProxy") as DefaultProxySection;
|
||||
WebProxy p;
|
||||
|
||||
if (sec == null)
|
||||
return GetSystemWebProxy ();
|
||||
|
||||
ProxyElement pe = sec.Proxy;
|
||||
|
||||
if ((pe.UseSystemDefault != ProxyElement.UseSystemDefaultValues.False) && (pe.ProxyAddress == null)) {
|
||||
IWebProxy proxy = GetSystemWebProxy ();
|
||||
|
||||
if (!(proxy is WebProxy))
|
||||
return proxy;
|
||||
|
||||
p = (WebProxy) proxy;
|
||||
} else
|
||||
p = new WebProxy ();
|
||||
|
||||
if (pe.ProxyAddress != null)
|
||||
p.Address = pe.ProxyAddress;
|
||||
|
||||
if (pe.BypassOnLocal != ProxyElement.BypassOnLocalValues.Unspecified)
|
||||
p.BypassProxyOnLocal = (pe.BypassOnLocal == ProxyElement.BypassOnLocalValues.True);
|
||||
|
||||
foreach(BypassElement elem in sec.BypassList)
|
||||
p.BypassArrayList.Add(elem.Address);
|
||||
|
||||
return p;
|
||||
#else
|
||||
return GetSystemWebProxy ();
|
||||
#endif
|
||||
}
|
||||
|
||||
static IWebProxy GetSystemWebProxy()
|
||||
{
|
||||
return System.Net.WebProxy.CreateDefaultProxy ();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
internal static object ClassSyncObject
|
||||
{
|
||||
@@ -292,6 +337,11 @@ namespace System.Net.Configuration
|
||||
{
|
||||
lock (DefaultProxySectionInternal.ClassSyncObject)
|
||||
{
|
||||
#if MONO
|
||||
var res = new DefaultProxySectionInternal();
|
||||
res.webProxy = GetDefaultProxy_UsingOldMonoCode ();
|
||||
return res;
|
||||
#else
|
||||
DefaultProxySection section = PrivilegedConfigurationManager.GetSection(ConfigurationStrings.DefaultProxySectionPath) as DefaultProxySection;
|
||||
if (section == null)
|
||||
return null;
|
||||
@@ -306,6 +356,7 @@ namespace System.Net.Configuration
|
||||
|
||||
throw new ConfigurationErrorsException(SR.GetString(SR.net_config_proxy), exception);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -300,6 +300,9 @@ namespace System.Net {
|
||||
}
|
||||
}
|
||||
|
||||
// Note: RequestBuffer may get moved in memory. If you dereference a pointer from inside the RequestBuffer,
|
||||
// you must use 'OriginalBlobAddress' below to adjust the location of the pointer to match the location of
|
||||
// RequestBuffer.
|
||||
internal byte[] RequestBuffer
|
||||
{
|
||||
get
|
||||
@@ -1061,7 +1064,7 @@ namespace System.Net {
|
||||
|
||||
m_TokenBindings = new List<TokenBinding>();
|
||||
|
||||
UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_TOKEN_BINDING_INFO* pTokenBindingInfo = GetTlsTokenBindingRequestInfo();
|
||||
UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_TOKEN_BINDING_INFO* pTokenBindingInfo = UnsafeNclNativeMethods.HttpApi.GetTlsTokenBindingRequestInfo(RequestBuffer, OriginalBlobAddress);
|
||||
|
||||
if (pTokenBindingInfo == null)
|
||||
{
|
||||
@@ -1116,23 +1119,6 @@ namespace System.Net {
|
||||
}
|
||||
}
|
||||
|
||||
private UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_TOKEN_BINDING_INFO* GetTlsTokenBindingRequestInfo() {
|
||||
fixed (byte* pMemoryBlob = RequestBuffer)
|
||||
{
|
||||
UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_V2* request = (UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_V2*)pMemoryBlob;
|
||||
|
||||
for (int i = 0; i < request->RequestInfoCount; i++)
|
||||
{
|
||||
UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_INFO* pThisInfo = &request->pRequestInfo[i];
|
||||
if (pThisInfo != null && pThisInfo->InfoType == UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_INFO_TYPE.HttpRequestInfoTypeSslTokenBinding)
|
||||
{
|
||||
return (UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_TOKEN_BINDING_INFO*)pThisInfo->pInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
internal void CheckDisposed() {
|
||||
if (m_IsDisposed) {
|
||||
throw new ObjectDisposedException(this.GetType().FullName);
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace System.Net {
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Runtime.Serialization;
|
||||
using Microsoft.Win32;
|
||||
using System.Collections.Generic;
|
||||
|
||||
internal static class IntPtrHelper {
|
||||
/*
|
||||
@@ -174,7 +175,6 @@ namespace System.Net {
|
||||
private static volatile IPAddress[] _LocalAddresses;
|
||||
private static object _LocalAddressesLock;
|
||||
|
||||
#if MONO_NOT_IMPLEMENTED
|
||||
#if !FEATURE_PAL
|
||||
|
||||
private static volatile NetworkAddressChangePolled s_AddressChange;
|
||||
@@ -287,6 +287,19 @@ namespace System.Net {
|
||||
}
|
||||
|
||||
#else // !FEATURE_PAL
|
||||
|
||||
internal static bool IsAddressLocal(IPAddress ipAddress) {
|
||||
IPAddress[] localAddresses = NclUtilities.LocalAddresses;
|
||||
for (int i = 0; i < localAddresses.Length; i++)
|
||||
{
|
||||
if (ipAddress.Equals(localAddresses[i], false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private const int HostNameBufferLength = 256;
|
||||
internal static string _LocalDomainName;
|
||||
|
||||
@@ -295,6 +308,9 @@ namespace System.Net {
|
||||
//
|
||||
private static IPHostEntry GetLocalHost()
|
||||
{
|
||||
#if MONO
|
||||
return Dns.GetHostByName (Dns.GetHostName ());
|
||||
#else
|
||||
//
|
||||
// IPv6 Changes: If IPv6 is enabled, we can't simply use the
|
||||
// old IPv4 gethostbyname(null). Instead we need
|
||||
@@ -337,6 +353,7 @@ namespace System.Net {
|
||||
|
||||
return Dns.NativeToHostEntry(nativePointer);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // GetLocalHost
|
||||
|
||||
@@ -402,7 +419,6 @@ namespace System.Net {
|
||||
}
|
||||
}
|
||||
#endif // !FEATURE_PAL
|
||||
#endif
|
||||
|
||||
private static object LocalAddressesLock
|
||||
{
|
||||
@@ -1390,6 +1406,7 @@ typedef struct _SCHANNEL_CRED
|
||||
ValidateManual = 0x08,
|
||||
NoDefaultCred = 0x10,
|
||||
ValidateAuto = 0x20,
|
||||
SendAuxRecord = 0x00200000,
|
||||
UseStrongCrypto = 0x00400000,
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if MONO
|
||||
#undef FEATURE_PAL
|
||||
#endif
|
||||
|
||||
namespace System.Net {
|
||||
|
||||
using System.IO;
|
||||
@@ -22,9 +26,11 @@ namespace System.Net {
|
||||
/// </devdoc>
|
||||
public class NetworkCredential : ICredentials,ICredentialsByHost {
|
||||
|
||||
#if FEATURE_MONO_CAS
|
||||
private static volatile EnvironmentPermission m_environmentUserNamePermission;
|
||||
private static volatile EnvironmentPermission m_environmentDomainNamePermission;
|
||||
private static readonly object lockingObject = new object();
|
||||
#endif
|
||||
private string m_domain;
|
||||
private string m_userName;
|
||||
#if !FEATURE_PAL
|
||||
@@ -85,6 +91,7 @@ namespace System.Net {
|
||||
}
|
||||
#endif //!FEATURE_PAL
|
||||
|
||||
#if FEATURE_MONO_CAS
|
||||
void InitializePart1() {
|
||||
if (m_environmentUserNamePermission == null) {
|
||||
lock(lockingObject) {
|
||||
@@ -95,7 +102,7 @@ namespace System.Net {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/// <devdoc>
|
||||
/// <para>
|
||||
@@ -104,8 +111,10 @@ namespace System.Net {
|
||||
/// </devdoc>
|
||||
public string UserName {
|
||||
get {
|
||||
#if FEATURE_MONO_CAS
|
||||
InitializePart1();
|
||||
m_environmentUserNamePermission.Demand();
|
||||
#endif
|
||||
return InternalGetUserName();
|
||||
}
|
||||
set {
|
||||
@@ -124,7 +133,9 @@ namespace System.Net {
|
||||
/// </devdoc>
|
||||
public string Password {
|
||||
get {
|
||||
#if FEATURE_MONO_CAS
|
||||
ExceptionHelper.UnmanagedPermission.Demand();
|
||||
#endif
|
||||
return InternalGetPassword();
|
||||
}
|
||||
set {
|
||||
@@ -151,7 +162,9 @@ namespace System.Net {
|
||||
/// </devdoc>
|
||||
public SecureString SecurePassword {
|
||||
get {
|
||||
#if FEATURE_MONO_CAS
|
||||
ExceptionHelper.UnmanagedPermission.Demand();
|
||||
#endif
|
||||
return InternalGetSecurePassword().Copy();
|
||||
}
|
||||
set {
|
||||
@@ -171,8 +184,10 @@ namespace System.Net {
|
||||
/// </devdoc>
|
||||
public string Domain {
|
||||
get {
|
||||
#if FEATURE_MONO_CAS
|
||||
InitializePart1();
|
||||
m_environmentDomainNamePermission.Demand();
|
||||
#endif
|
||||
return InternalGetDomain();
|
||||
}
|
||||
set {
|
||||
|
||||
@@ -592,9 +592,17 @@ namespace System.Net.Security {
|
||||
KeyExchangeStrength));
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// If an exception emerges synchronously, the asynchronous operation was not
|
||||
// initiated, so no operation is in progress.
|
||||
_NestedAuth = 0;
|
||||
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (lazyResult == null || _Exception != null)
|
||||
if (lazyResult == null)
|
||||
{
|
||||
_NestedAuth = 0;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,9 @@ namespace System.Net {
|
||||
return m_BindIPEndPointDelegate;
|
||||
}
|
||||
set {
|
||||
#if FEATURE_MONO_CAS
|
||||
ExceptionHelper.InfrastructurePermission.Demand();
|
||||
#endif
|
||||
m_BindIPEndPointDelegate = value;
|
||||
}
|
||||
}
|
||||
@@ -458,11 +460,13 @@ namespace System.Net {
|
||||
throw new NotSupportedException(SR.GetString(SR.net_servicePointAddressNotSupportedInHostMode));
|
||||
}
|
||||
|
||||
#if FEATURE_MONO_CAS
|
||||
// Don't let low-trust apps discover the proxy information.
|
||||
if (m_ProxyServicePoint)
|
||||
{
|
||||
ExceptionHelper.WebPermissionUnrestricted.Demand();
|
||||
}
|
||||
#endif
|
||||
|
||||
return m_Address;
|
||||
}
|
||||
|
||||
@@ -247,12 +247,15 @@ namespace System.Net {
|
||||
private static volatile CertPolicyValidationCallback s_CertPolicyValidationCallback = new CertPolicyValidationCallback();
|
||||
private static volatile ServerCertValidationCallback s_ServerCertValidationCallback = null;
|
||||
|
||||
private const string sendAuxRecordValueName = "SchSendAuxRecord";
|
||||
private const string sendAuxRecordAppSetting = "System.Net.ServicePointManager.SchSendAuxRecord";
|
||||
private const string strongCryptoValueName = "SchUseStrongCrypto";
|
||||
private const string secureProtocolAppSetting = "System.Net.ServicePointManager.SecurityProtocol";
|
||||
|
||||
private static object disableStrongCryptoLock = new object();
|
||||
private static volatile bool disableStrongCryptoInitialized = false;
|
||||
private static object configurationLoadedLock = new object();
|
||||
private static volatile bool configurationLoaded = false;
|
||||
private static bool disableStrongCrypto = false;
|
||||
private static bool disableSendAuxRecord = false;
|
||||
|
||||
private static SecurityProtocolType s_SecurityProtocolType = SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;
|
||||
|
||||
@@ -427,11 +430,11 @@ namespace System.Net {
|
||||
[SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "Reviewed for thread-safety")]
|
||||
public static SecurityProtocolType SecurityProtocol {
|
||||
get {
|
||||
EnsureStrongCryptoSettingsInitialized();
|
||||
EnsureConfigurationLoaded();
|
||||
return s_SecurityProtocolType;
|
||||
}
|
||||
set {
|
||||
EnsureStrongCryptoSettingsInitialized();
|
||||
EnsureConfigurationLoaded();
|
||||
ValidateSecurityProtocol(value);
|
||||
s_SecurityProtocolType = value;
|
||||
}
|
||||
@@ -640,77 +643,118 @@ namespace System.Net {
|
||||
|
||||
internal static bool DisableStrongCrypto {
|
||||
get {
|
||||
EnsureStrongCryptoSettingsInitialized();
|
||||
return (bool)disableStrongCrypto;
|
||||
EnsureConfigurationLoaded();
|
||||
return disableStrongCrypto;
|
||||
}
|
||||
}
|
||||
|
||||
private static void EnsureStrongCryptoSettingsInitialized() {
|
||||
|
||||
if (disableStrongCryptoInitialized) {
|
||||
internal static bool DisableSendAuxRecord {
|
||||
get {
|
||||
EnsureConfigurationLoaded();
|
||||
return disableSendAuxRecord;
|
||||
}
|
||||
}
|
||||
|
||||
private static void EnsureConfigurationLoaded() {
|
||||
if (configurationLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
lock (disableStrongCryptoLock) {
|
||||
if (disableStrongCryptoInitialized) {
|
||||
lock (configurationLoadedLock) {
|
||||
if (configurationLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
bool disableStrongCryptoInternal = false;
|
||||
int schUseStrongCryptoKeyValue = 0;
|
||||
LoadDisableStrongCryptoConfiguration();
|
||||
LoadDisableSendAuxRecordConfiguration();
|
||||
|
||||
if (LocalAppContextSwitches.DontEnableSchUseStrongCrypto)
|
||||
{
|
||||
//.Net 4.5.2 and below will default to false unless the registry key is specifically set to 1.
|
||||
schUseStrongCryptoKeyValue =
|
||||
RegistryConfiguration.GlobalConfigReadInt(strongCryptoValueName, 0);
|
||||
configurationLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
disableStrongCryptoInternal = schUseStrongCryptoKeyValue != 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// .Net 4.6 and above will default to true unless the registry key is specifically set to 0.
|
||||
schUseStrongCryptoKeyValue =
|
||||
RegistryConfiguration.GlobalConfigReadInt(strongCryptoValueName, 1);
|
||||
private static void LoadDisableStrongCryptoConfiguration() {
|
||||
try {
|
||||
bool disableStrongCryptoInternal = false;
|
||||
int schUseStrongCryptoKeyValue = 0;
|
||||
|
||||
disableStrongCryptoInternal = schUseStrongCryptoKeyValue == 0;
|
||||
}
|
||||
|
||||
if (disableStrongCryptoInternal) {
|
||||
// Revert the SecurityProtocol selection to the legacy combination.
|
||||
s_SecurityProtocolType = SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;
|
||||
}
|
||||
else {
|
||||
s_SecurityProtocolType =
|
||||
SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
|
||||
if (LocalAppContextSwitches.DontEnableSchUseStrongCrypto) {
|
||||
//.Net 4.5.2 and below will default to false unless the registry key is specifically set to 1.
|
||||
schUseStrongCryptoKeyValue =
|
||||
RegistryConfiguration.GlobalConfigReadInt(strongCryptoValueName, 0);
|
||||
|
||||
string appSetting = RegistryConfiguration.AppConfigReadString(secureProtocolAppSetting, null);
|
||||
|
||||
SecurityProtocolType value;
|
||||
try {
|
||||
value = (SecurityProtocolType)Enum.Parse(typeof(SecurityProtocolType), appSetting);
|
||||
ValidateSecurityProtocol(value);
|
||||
s_SecurityProtocolType = value;
|
||||
}
|
||||
// Ignore all potential exceptions caused by Enum.Parse.
|
||||
catch (ArgumentNullException) { }
|
||||
catch (ArgumentException) { }
|
||||
catch (NotSupportedException) { }
|
||||
catch (OverflowException) { }
|
||||
}
|
||||
|
||||
disableStrongCrypto = disableStrongCryptoInternal;
|
||||
disableStrongCryptoInitialized = true;
|
||||
disableStrongCryptoInternal = schUseStrongCryptoKeyValue != 1;
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) {
|
||||
throw;
|
||||
else {
|
||||
// .Net 4.6 and above will default to true unless the registry key is specifically set to 0.
|
||||
schUseStrongCryptoKeyValue =
|
||||
RegistryConfiguration.GlobalConfigReadInt(strongCryptoValueName, 1);
|
||||
|
||||
disableStrongCryptoInternal = schUseStrongCryptoKeyValue == 0;
|
||||
}
|
||||
|
||||
if (disableStrongCryptoInternal) {
|
||||
// Revert the SecurityProtocol selection to the legacy combination.
|
||||
s_SecurityProtocolType = SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;
|
||||
}
|
||||
else {
|
||||
s_SecurityProtocolType =
|
||||
SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
|
||||
|
||||
string appSetting = RegistryConfiguration.AppConfigReadString(secureProtocolAppSetting, null);
|
||||
|
||||
SecurityProtocolType value;
|
||||
try {
|
||||
value = (SecurityProtocolType)Enum.Parse(typeof(SecurityProtocolType), appSetting);
|
||||
ValidateSecurityProtocol(value);
|
||||
s_SecurityProtocolType = value;
|
||||
}
|
||||
// Ignore all potential exceptions caused by Enum.Parse.
|
||||
catch (ArgumentNullException) { }
|
||||
catch (ArgumentException) { }
|
||||
catch (NotSupportedException) { }
|
||||
catch (OverflowException) { }
|
||||
}
|
||||
|
||||
disableStrongCrypto = disableStrongCryptoInternal;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void LoadDisableSendAuxRecordConfiguration() {
|
||||
try {
|
||||
if (LocalAppContextSwitches.DontEnableSchSendAuxRecord) {
|
||||
disableSendAuxRecord = true;
|
||||
return;
|
||||
}
|
||||
|
||||
int schSendAuxRecordKeyValue = 1;
|
||||
schSendAuxRecordKeyValue = RegistryConfiguration.AppConfigReadInt(sendAuxRecordAppSetting, 1);
|
||||
if (schSendAuxRecordKeyValue == 0) {
|
||||
disableSendAuxRecord = true;
|
||||
return;
|
||||
}
|
||||
|
||||
schSendAuxRecordKeyValue = RegistryConfiguration.GlobalConfigReadInt(sendAuxRecordValueName, 1);
|
||||
if (schSendAuxRecordKeyValue == 0) {
|
||||
disableSendAuxRecord = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ReusePort {
|
||||
get {
|
||||
EnsureReusePortSettingsInitialized();
|
||||
|
||||
@@ -1 +1 @@
|
||||
1d92faa541f6a2d6c5a5700a11dc0113895d3e89
|
||||
c8a3da853476918de06973dfe4cb78058a0e20d4
|
||||
@@ -1 +1 @@
|
||||
7cf970ed013f48125de2c07a4a866a49c4cbd648
|
||||
680ea9813968ee030704b14352a20cc2eaaede54
|
||||
@@ -247,7 +247,7 @@ namespace System.Net {
|
||||
private WebHeaderCollectionType m_Type;
|
||||
|
||||
#if MONO
|
||||
internal bool AllowMultiValues (string name)
|
||||
internal static bool AllowMultiValues (string name)
|
||||
{
|
||||
var hinfo = HInfo[name];
|
||||
// Is common header which supports multi value or it's unknown header
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if MONO
|
||||
#undef FEATURE_PAL
|
||||
#endif
|
||||
namespace System.Net {
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
@@ -53,6 +56,7 @@ namespace System.Net {
|
||||
private AuthenticationLevel m_AuthenticationLevel;
|
||||
private TokenImpersonationLevel m_ImpersonationLevel;
|
||||
#endif
|
||||
|
||||
private RequestCachePolicy m_CachePolicy;
|
||||
private RequestCacheProtocol m_CacheProtocol;
|
||||
private RequestCacheBinding m_CacheBinding;
|
||||
@@ -361,7 +365,9 @@ namespace System.Net {
|
||||
throw new ArgumentNullException("creator");
|
||||
}
|
||||
|
||||
#if FEATURE_MONO_CAS
|
||||
ExceptionHelper.WebPermissionUnrestricted.Demand();
|
||||
#endif
|
||||
|
||||
// Lock this object, then walk down PrefixList looking for a place to
|
||||
// to insert this prefix.
|
||||
@@ -523,7 +529,11 @@ namespace System.Net {
|
||||
lock (InternalSyncObject) {
|
||||
if (s_PrefixList == null) {
|
||||
GlobalLog.Print("WebRequest::Initialize(): calling ConfigurationManager.GetSection()");
|
||||
#if MONO
|
||||
s_PrefixList = PopulatePrefixList ();
|
||||
#else
|
||||
s_PrefixList = WebRequestModulesSectionInternal.GetSection().WebRequestModules;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -535,6 +545,30 @@ namespace System.Net {
|
||||
}
|
||||
}
|
||||
|
||||
#if MONO
|
||||
static ArrayList PopulatePrefixList ()
|
||||
{
|
||||
var res = new ArrayList();
|
||||
|
||||
#if MOBILE || !CONFIGURATION_DEP
|
||||
IWebRequestCreate http = new HttpRequestCreator ();
|
||||
res.Add(new WebRequestPrefixElement("http", http));
|
||||
res.Add(new WebRequestPrefixElement("https", http));
|
||||
res.Add(new WebRequestPrefixElement("file", new FileWebRequestCreator ()));
|
||||
res.Add(new WebRequestPrefixElement("ftp", new FtpRequestCreator ()));
|
||||
#else
|
||||
object cfg = ConfigurationManager.GetSection ("system.net/webRequestModules");
|
||||
WebRequestModulesSection s = cfg as WebRequestModulesSection;
|
||||
if (s != null) {
|
||||
foreach (WebRequestModuleElement el in s.WebRequestModules)
|
||||
res.Add (new WebRequestPrefixElement(el.Prefix, el.Type));
|
||||
}
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// constructors
|
||||
|
||||
/// <devdoc>
|
||||
@@ -588,8 +622,10 @@ namespace System.Net {
|
||||
return RequestCacheManager.GetBinding(string.Empty).Policy;
|
||||
}
|
||||
set {
|
||||
#if FEATURE_MONO_CAS
|
||||
// This is a replacement of RequestCachePermission demand since we are not including the latest in the product.
|
||||
ExceptionHelper.WebPermissionUnrestricted.Demand();
|
||||
#endif
|
||||
|
||||
RequestCacheBinding binding = RequestCacheManager.GetBinding(string.Empty);
|
||||
RequestCacheManager.SetBinding(string.Empty, new RequestCacheBinding(binding.Cache, binding.Validator, value));
|
||||
@@ -975,7 +1011,7 @@ namespace System.Net {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if !MONO
|
||||
// Methods to retrieve the context of the "reading phase" and of the "writing phase" of the request.
|
||||
// Each request type can define what goes into what phase. Typically, the writing phase corresponds to
|
||||
// GetRequestStream() and the reading phase to GetResponse(), but if there's no request body, both phases
|
||||
@@ -996,7 +1032,7 @@ namespace System.Net {
|
||||
{
|
||||
throw ExceptionHelper.MethodNotImplementedException;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
//
|
||||
@@ -1072,13 +1108,17 @@ namespace System.Net {
|
||||
{
|
||||
get
|
||||
{
|
||||
#if FEATURE_MONO_CAS
|
||||
ExceptionHelper.WebPermissionUnrestricted.Demand();
|
||||
#endif
|
||||
return InternalDefaultWebProxy;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
#if FEATURE_MONO_CAS
|
||||
ExceptionHelper.WebPermissionUnrestricted.Demand();
|
||||
#endif
|
||||
InternalDefaultWebProxy = value;
|
||||
}
|
||||
}
|
||||
@@ -1088,13 +1128,20 @@ namespace System.Net {
|
||||
//
|
||||
public static IWebProxy GetSystemWebProxy()
|
||||
{
|
||||
#if FEATURE_MONO_CAS
|
||||
ExceptionHelper.WebPermissionUnrestricted.Demand();
|
||||
#endif
|
||||
return InternalGetSystemWebProxy();
|
||||
}
|
||||
|
||||
internal static IWebProxy InternalGetSystemWebProxy()
|
||||
{
|
||||
#if MONO
|
||||
// FIXME: Need to break mobile internal API
|
||||
return WebProxy.CreateDefaultProxy();
|
||||
#else
|
||||
return new WebProxyWrapperOpaque(new WebProxy(true));
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1162,7 +1209,7 @@ namespace System.Net {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if !MONO
|
||||
//
|
||||
internal void SetupCacheProtocol(Uri uri)
|
||||
{
|
||||
@@ -1242,5 +1289,6 @@ namespace System.Net {
|
||||
s_EtwFireEndGetRequestStream(this, success, synchronous);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} // class WebRequest
|
||||
} // namespace System.Net
|
||||
|
||||
@@ -393,7 +393,7 @@ namespace System.Net.Security {
|
||||
if (store != null)
|
||||
{
|
||||
collectionEx = store.Certificates.Find(X509FindType.FindByThumbprint, certHash, false);
|
||||
if (collectionEx.Count > 0 && collectionEx[0].PrivateKey != null)
|
||||
if (collectionEx.Count > 0 && collectionEx[0].HasPrivateKey)
|
||||
{
|
||||
if (Logging.On) Logging.PrintInfo(Logging.Web, this, SR.GetString(SR.net_log_found_cert_in_store, (m_ServerMode ? "LocalMachine" : "CurrentUser")));
|
||||
return collectionEx[0];
|
||||
@@ -404,7 +404,7 @@ namespace System.Net.Security {
|
||||
if (store != null)
|
||||
{
|
||||
collectionEx = store.Certificates.Find(X509FindType.FindByThumbprint, certHash, false);
|
||||
if (collectionEx.Count > 0 && collectionEx[0].PrivateKey != null)
|
||||
if (collectionEx.Count > 0 && collectionEx[0].HasPrivateKey)
|
||||
{
|
||||
if (Logging.On) Logging.PrintInfo(Logging.Web, this, SR.GetString(SR.net_log_found_cert_in_store, (m_ServerMode ? "CurrentUser" : "LocalMachine")));
|
||||
return collectionEx[0];
|
||||
@@ -791,6 +791,12 @@ namespace System.Net.Security {
|
||||
else
|
||||
{
|
||||
SecureCredential.Flags flags = SecureCredential.Flags.ValidateManual | SecureCredential.Flags.NoDefaultCred;
|
||||
|
||||
if (!ServicePointManager.DisableSendAuxRecord)
|
||||
{
|
||||
flags |= SecureCredential.Flags.SendAuxRecord;
|
||||
}
|
||||
|
||||
if (!ServicePointManager.DisableStrongCrypto
|
||||
&& ((m_ProtocolFlags & (SchProtocols.Tls10 | SchProtocols.Tls11 | SchProtocols.Tls12)) != 0)
|
||||
&& (m_EncryptionPolicy != EncryptionPolicy.AllowNoEncryption) && (m_EncryptionPolicy != EncryptionPolicy.NoEncryption))
|
||||
@@ -876,7 +882,14 @@ namespace System.Net.Security {
|
||||
}
|
||||
else
|
||||
{
|
||||
SecureCredential secureCredential = new SecureCredential(SecureCredential.CurrentVersion, selectedCert, SecureCredential.Flags.Zero, m_ProtocolFlags, m_EncryptionPolicy);
|
||||
SecureCredential.Flags flags = SecureCredential.Flags.Zero;
|
||||
|
||||
if (!ServicePointManager.DisableSendAuxRecord)
|
||||
{
|
||||
flags |= SecureCredential.Flags.SendAuxRecord;
|
||||
}
|
||||
|
||||
SecureCredential secureCredential = new SecureCredential(SecureCredential.CurrentVersion, selectedCert, flags, m_ProtocolFlags, m_EncryptionPolicy);
|
||||
m_CredentialsHandle = AcquireCredentialsHandle(CredentialUse.Inbound, ref secureCredential);
|
||||
thumbPrint = guessedThumbPrint;
|
||||
m_ServerCertificate = localCertificate;
|
||||
|
||||
@@ -20,8 +20,13 @@ namespace System.Net
|
||||
{
|
||||
internal Semaphore(int initialCount, int maxCount) : base() {
|
||||
lock (this) {
|
||||
#if MONO
|
||||
int errorCode;
|
||||
Handle = System.Threading.Semaphore.CreateSemaphore_internal(initialCount, maxCount, null, out errorCode);
|
||||
#else
|
||||
//
|
||||
Handle = UnsafeNclNativeMethods.CreateSemaphore(IntPtr.Zero, initialCount, maxCount, IntPtr.Zero);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,14 +41,19 @@ namespace System.Net
|
||||
*/
|
||||
|
||||
internal bool ReleaseSemaphore() {
|
||||
#if DEBUG
|
||||
#if MONO
|
||||
int previousCount;
|
||||
return System.Threading.Semaphore.ReleaseSemaphore_internal (Handle, 1, out previousCount);
|
||||
#else
|
||||
#if DEBUG
|
||||
int previousCount;
|
||||
bool success = UnsafeNclNativeMethods.ReleaseSemaphore(Handle, 1, out previousCount);
|
||||
GlobalLog.Print("ReleaseSemaphore#"+ValidationHelper.HashString(this)+" success:"+success+" previousCount:"+previousCount.ToString());
|
||||
return success;
|
||||
#else
|
||||
return UnsafeNclNativeMethods.ReleaseSemaphore(Handle, 1, IntPtr.Zero);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -182,7 +182,9 @@ namespace System.Net {
|
||||
|
||||
static TimerThread() {
|
||||
s_ThreadEvents = new WaitHandle[] { s_ThreadShutdownEvent, s_ThreadReadyEvent };
|
||||
#if MONO_FEATURE_MULTIPLE_APPDOMAINS
|
||||
AppDomain.CurrentDomain.DomainUnload += new EventHandler(OnDomainUnload);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user