Imported Upstream version 4.8.0.309

Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-11-10 13:04:39 +00:00
parent ee1447783b
commit 94b2861243
4912 changed files with 390737 additions and 49310 deletions

View File

@@ -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 {

View File

@@ -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
}
}

View File

@@ -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);

View File

@@ -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,
}

View File

@@ -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 {

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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();

View File

@@ -1 +1 @@
1d92faa541f6a2d6c5a5700a11dc0113895d3e89
c8a3da853476918de06973dfe4cb78058a0e20d4

View File

@@ -1 +1 @@
7cf970ed013f48125de2c07a4a866a49c4cbd648
680ea9813968ee030704b14352a20cc2eaaede54

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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
}
/*

View File

@@ -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>

View File

@@ -414,7 +414,9 @@ namespace System.Net {
/// </devdoc>
[Obsolete("This method has been deprecated. Please use the proxy selected for you by default. http://go.microsoft.com/fwlink/?linkid=14202")]
public static WebProxy GetDefaultProxy() {
#if FEATURE_MONO_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
return new WebProxy(true);
}
@@ -435,7 +437,9 @@ namespace System.Net {
if (useRegistry) {
// just make the proxy advanced, don't populate with any settings
// note - this will happen in the context of the user performing the deserialization (their proxy settings get read)
#if FEATURE_MONO_CAS
ExceptionHelper.WebPermissionUnrestricted.Demand();
#endif
UnsafeUpdateFromRegistry();
return;
}
@@ -497,6 +501,30 @@ namespace System.Net {
}
}
#if MONO
public static IWebProxy CreateDefaultProxy ()
{
#if FEATURE_NO_BSD_SOCKETS
throw new PlatformNotSupportedException ();
#elif MONOTOUCH
return Mono.Net.CFNetwork.GetDefaultProxy ();
#elif MONODROID
// Return the system web proxy. This only works for ICS+.
var data = AndroidPlatform.GetDefaultProxy ();
if (data != null)
return data;
#else
if (Platform.IsMacOS) {
var data = Mono.Net.CFNetwork.GetDefaultProxy ();
if (data != null)
return data;
}
#endif
return new WebProxy (true);
}
#endif
// This constructor is used internally to make WebProxies that read their state from the registry.
//
internal WebProxy(bool enableAutoproxy)
@@ -515,7 +543,7 @@ namespace System.Net {
internal void UnsafeUpdateFromRegistry() {
GlobalLog.Assert(!_UseRegistry, "WebProxy#{0}::UnsafeUpdateFromRegistry()|_UseRegistry ScriptEngine#{1}", ValidationHelper.HashString(this), ValidationHelper.HashString(m_ScriptEngine));
_UseRegistry = true;
#if !FEATURE_PAL
#if !FEATURE_PAL || !MOBILE
ScriptEngine = new AutoWebProxyScriptEngine(this, true);
WebProxyData webProxyData = ScriptEngine.GetWebProxyData();

View File

@@ -443,6 +443,11 @@ namespace System {
{
Uri result;
#if MONO
if (uriKind == UriKind.RelativeOrAbsolute)
uriKind = DotNetRelativeOrAbsolute;
#endif
if (!Uri.TryCreate(uriString, uriKind, out result))
return false;