Imported Upstream version 4.4.0.40

Former-commit-id: 6427cc082e74df30afc535fd906a3494b74b0817
This commit is contained in:
Xamarin Public Jenkins
2016-03-16 12:38:19 -04:00
parent f3e3aab35a
commit a632333cc7
110 changed files with 1496 additions and 556 deletions

View File

@@ -160,7 +160,7 @@ namespace Mono.Net.Security
certValidationCallback = new ServerCertValidationCallback (callback);
}
certSelectionCallback = Private.CallbackHelpers.MonoToInternal (settings.ClientCertificateSelectionCallback);
fallbackToSPM = settings.UseServicePointManagerCallback;
fallbackToSPM = settings.UseServicePointManagerCallback ?? stream != null;
}
if (stream != null) {
@@ -264,7 +264,7 @@ namespace Mono.Net.Security
leaf = certs [0];
if (tlsStream != null)
request.ServicePoint.SetServerCertificate (leaf);
request.ServicePoint.UpdateServerCertificate (leaf);
if (leaf == null) {
errors |= SslPolicyErrors.RemoteCertificateNotAvailable;

View File

@@ -109,13 +109,19 @@ namespace Mono.Net.Security
ServicePointManager.CheckCertificateRevocationList);
status = WebExceptionStatus.Success;
} catch (Exception ex) {
status = WebExceptionStatus.SecureChannelFailure;
throw;
} finally {
if (CertificateValidationFailed)
status = WebExceptionStatus.TrustFailure;
request.ServicePoint.SetClientCertificate (sslStream.InternalLocalCertificate);
if (status != WebExceptionStatus.Success)
if (status == WebExceptionStatus.Success)
request.ServicePoint.UpdateClientCertificate (sslStream.InternalLocalCertificate);
else {
request.ServicePoint.UpdateClientCertificate (null);
sslStream = null;
}
}
try {

File diff suppressed because it is too large Load Diff

View File

@@ -1 +1 @@
8d48b675ae8cf9ed8a03cab67569bb1c49d9033d
0f1c977a71d57169dc91c54c8baa329f65d18b38

View File

@@ -593,6 +593,7 @@ namespace System.Net
CheckRequestStarted ();
proxy = value;
servicePoint = null; // we may need a new one
GetServicePoint ();
}
}
@@ -969,11 +970,17 @@ namespace System.Net
}
}
if (!requestSent) {
if (requestSent)
return;
try {
requestSent = true;
redirects = 0;
servicePoint = GetServicePoint ();
abortHandler = servicePoint.SendRequest (this, connectionGroup);
} catch (Exception ex) {
aread.SetCompleted (synch, ex);
aread.DoCallback ();
}
});

View File

@@ -49,8 +49,6 @@ namespace System.Net
DateTime idleSince;
DateTime lastDnsResolve;
Version protocolVersion;
X509Certificate certificate;
X509Certificate clientCertificate;
IPHostEntry host;
bool usesProxy;
Dictionary<string,WebConnectionGroup> groups;
@@ -92,14 +90,6 @@ namespace System.Net
set { endPointCallback = value; }
}
public X509Certificate Certificate {
get { return certificate; }
}
public X509Certificate ClientCertificate {
get { return clientCertificate; }
}
[MonoTODO]
public int ConnectionLeaseTimeout
{
@@ -413,20 +403,55 @@ namespace System.Net
return false;
}
internal void SetServerCertificate (X509Certificate server)
//
// Copied from the referencesource
//
object m_ServerCertificateOrBytes;
object m_ClientCertificateOrBytes;
/// <devdoc>
/// <para>
/// Gets the certificate received for this <see cref='System.Net.ServicePoint'/>.
/// </para>
/// </devdoc>
public X509Certificate Certificate {
get {
object chkCert = m_ServerCertificateOrBytes;
if (chkCert != null && chkCert.GetType() == typeof(byte[]))
return (X509Certificate)(m_ServerCertificateOrBytes = new X509Certificate((byte[]) chkCert));
else
return chkCert as X509Certificate;
}
}
internal void UpdateServerCertificate(X509Certificate certificate)
{
var cloned = server != null ? new X509Certificate (server) : null;
var old = Interlocked.Exchange (ref certificate, cloned);
if (old != null)
old.Dispose ();
if (certificate != null)
m_ServerCertificateOrBytes = certificate.GetRawCertData();
else
m_ServerCertificateOrBytes = null;
}
internal void SetClientCertificate (X509Certificate clientCertificate)
/// <devdoc>
/// <para>
/// Gets the Client Certificate sent by us to the Server.
/// </para>
/// </devdoc>
public X509Certificate ClientCertificate {
get {
object chkCert = m_ClientCertificateOrBytes;
if (chkCert != null && chkCert.GetType() == typeof(byte[]))
return (X509Certificate)(m_ClientCertificateOrBytes = new X509Certificate((byte[]) chkCert));
else
return chkCert as X509Certificate;
}
}
internal void UpdateClientCertificate(X509Certificate certificate)
{
var cloned = clientCertificate != null ? new X509Certificate (clientCertificate) : null;
var old = Interlocked.Exchange (ref clientCertificate, cloned);
if (old != null)
old.Dispose ();
if (certificate != null)
m_ClientCertificateOrBytes = certificate.GetRawCertData();
else
m_ClientCertificateOrBytes = null;
}
internal bool CallEndPointDelegate (Socket sock, IPEndPoint remote)

View File

@@ -114,7 +114,7 @@ namespace System.Net
// Static properties
private static ICertificatePolicy policy = new DefaultCertificatePolicy ();
private static ICertificatePolicy policy;
private static int defaultConnectionLimit = DefaultPersistentConnectionLimit;
private static int maxServicePointIdleTime = 100000; // 100 seconds
private static int maxServicePoints = 0;
@@ -174,7 +174,11 @@ namespace System.Net
[Obsolete ("Use ServerCertificateValidationCallback instead", false)]
public static ICertificatePolicy CertificatePolicy {
get { return policy; }
get {
if (policy == null)
Interlocked.CompareExchange (ref policy, new DefaultCertificatePolicy (), null);
return policy;
}
set { policy = value; }
}
@@ -328,7 +332,7 @@ namespace System.Net
usesProxy = true;
bool isSecure = address.Scheme == "https";
address = proxy.GetProxy (address);
if (address.Scheme != "http" && !isSecure)
if (address.Scheme != "http")
throw new NotSupportedException ("Proxy scheme not supported.");
if (isSecure && address.Scheme == "http")

View File

@@ -419,6 +419,7 @@ namespace System.Net
status = tlsStream.ExceptionStatus;
else if (!request.Aborted)
status = WebExceptionStatus.ConnectFailure;
connect_exception = ex;
return false;
}
@@ -992,9 +993,6 @@ namespace System.Net
internal bool EndWrite (HttpWebRequest request, bool throwOnError, IAsyncResult result)
{
if (request.FinishedReading)
return true;
Stream s = null;
lock (this) {
if (status == WebExceptionStatus.RequestCanceled)

View File

@@ -397,6 +397,22 @@ namespace MonoTests.System.IO.Compression
compressing.Close ();
backing.Close ();
}
[Test]
public void Bug34916_Inflate ()
{
var base64String = @"H4sIAAAAAAAAA6yVu27bQBBF/4VtZGHeD3ZJmhTp5C5IIUiEIcCWDEUugiD/nmEQwYRNURFAsuFwd2exZ++d+farud89davT+um5aRsC1DuEO+R7lJayRV9m5gegFqBZNB83m5fjevOzadGWUPHjaXd62XYVEy3Z04wiMTKIX0dfV0G/6FO3Pu72D/+iL916W9GbOV/X58SaS6zEKKyoGUA1eNg/nLfF2jUEBBNMtT4Wzeq567Z9HkZkE1Osf93msN/+WO32m+7zsavsh30/BUU8fy+uUCC+QIHpPQW1RAXkEGWUmSnUy2iUYSMYOGpARYViiIHcqY5kExS8rg2vY8gLGEjeYsClBVE4ORQHz3kxsEF4iS01xzBIZkgYQcYQQ7C54LQaIrxWn5+4ioT1BiRQN8Fh6MrOPjOS9Eh3M8YRJJQMZioJkUODFA8RNJ9AYuYBNyGJW5D0oi3/EpZ3dWYk5X5PN81RJGJgDATMQ5X02nFS1imVlMGvu0XwBg5/K1hY1U8tecxcNDy1/FAnG+OAQSi9PliHRaNUiuoxQYFB6T8oyAUKEu9LJ6oipbr1spyZArhWX6qbi7EOUrs7SCAoDNVgzKagMlUz+q6DQ4N8/yM=";
byte[] byteArray = Convert.FromBase64String(base64String);
string unZipped = null;
using (var zippedMemoryStream = new MemoryStream (byteArray))
using (var gZipStream = new GZipStream (zippedMemoryStream, CompressionMode.Decompress))
using (var unzippedMemStream = new MemoryStream())
using (var unZippedStream = new StreamReader (gZipStream, Encoding.UTF8)) {
unZipped = unZippedStream.ReadToEnd ();
}
}
}
}

View File

@@ -1 +1 @@
2f85b7b795ef33f0b58ccc3b51269444520bdab9
a0e19d4f2d15d6d856fcf37ff33c86c1173274d5

View File

@@ -0,0 +1 @@
#include System.dll.sources