Imported Upstream version 4.4.0.182

Former-commit-id: ea38b2115ac3af9a394fe6cddf2be2acd11bc002
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-06-14 09:39:34 +00:00
parent ee13743634
commit 180e8b1935
125 changed files with 1658 additions and 521 deletions

View File

@@ -1035,7 +1035,7 @@ namespace Microsoft.Build.BuildEngine {
evaluatedProperties.AddProperty (new BuildProperty ("OS", OS, PropertyType.Environment));
#if XBUILD_12
// see http://msdn.microsoft.com/en-us/library/vstudio/hh162058(v=vs.120).aspx
if (effective_tools_version == "12.0") {
if (effective_tools_version == "12.0" || effective_tools_version == "14.0") {
evaluatedProperties.AddProperty (new BuildProperty ("MSBuildToolsPath32", toolsPath, PropertyType.Reserved));
var frameworkToolsPath = ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version451);

View File

@@ -128,6 +128,10 @@ namespace Microsoft.Build.Tasks {
relatedFiles = tempRelatedFiles.Values.ToArray ();
resolvedDependencyFiles = tempResolvedDepFiles.Values.ToArray ();
#if XBUILD_14
DependsOnSystemRuntime = resolvedDependencyFiles.Any (x => Path.GetFileName (x.ItemSpec) == "System.Runtime.dll").ToString ();
#endif
tempResolvedFiles.Clear ();
tempCopyLocalFiles.Clear ();
tempSatelliteFiles.Clear ();

View File

@@ -40,65 +40,16 @@ namespace Mono.Security.Protocol.Tls
public static CipherSuiteCollection GetSupportedCiphers (bool server, SecurityProtocolType protocol)
{
CipherSuiteCollection suites;
switch (protocol) {
case SecurityProtocolType.Default:
case SecurityProtocolType.Tls:
suites = CipherSuiteFactory.GetTls1SupportedCiphers ();
break;
return CipherSuiteFactory.GetTls1SupportedCiphers ();
case SecurityProtocolType.Ssl3:
suites = CipherSuiteFactory.GetSsl3SupportedCiphers ();
break;
return CipherSuiteFactory.GetSsl3SupportedCiphers ();
case SecurityProtocolType.Ssl2:
default:
throw new NotSupportedException ("Unsupported security protocol type");
}
IEnumerable<string> list = null;
#if INSIDE_SYSTEM
// if SSL/TLS support is built-in System.dll (e.g. monotouch) then we can access ServicePointManager
// extension directly
var cb = server ? ServicePointManager.ServerCipherSuitesCallback : ServicePointManager.ClientCipherSuitesCallback;
if (cb == null)
return suites; // e.g. no callback was set
list = cb ((System.Net.SecurityProtocolType) (int) protocol, suites.GetNames ());
#elif !BOOTSTRAP_BASIC
// Mono.Security must work on MS.NET so it cannot depend on any Mono-specific extensions
PropertyInfo pi = null;
if (server) {
if (server_callback == null)
server_callback = spm.GetProperty ("ServerCipherSuitesCallback", BindingFlags.Static | BindingFlags.Public);
pi = server_callback;
} else {
if (client_callback == null)
client_callback = spm.GetProperty ("ClientCipherSuitesCallback", BindingFlags.Static | BindingFlags.Public);
pi = client_callback;
}
if (pi == null)
return suites; // e.g. MS runtime - return every supported suites
var cb = (Delegate) pi.GetGetMethod ().Invoke (null, null);
if (cb == null)
return suites; // e.g. no callback was set - return every supported suites
list = (IEnumerable<string>) cb.DynamicInvoke (new object[] {
(System.Net.SecurityProtocolType) (int) protocol, suites.GetNames ()
});
#else
// TODO: right now the callback is only available when using System.Net.* types for SSL/TLS
return suites;
#endif
CipherSuiteCollection allowed = new CipherSuiteCollection (protocol);
if (list != null) {
foreach (var name in list) {
// add any supported (ignore unknowns) ciphers requested by the callback
var cipher = suites [name];
if (cipher != null)
allowed.Add (cipher);
}
}
return allowed;
}
#region Private Static Methods

View File

@@ -73,16 +73,12 @@ namespace Mono.Net.Security
public static X509Chain CreateX509Chain (XX509CertificateCollection certs)
{
var chain = new X509Chain ();
chain.ChainPolicy = new X509ChainPolicy ();
chain.ChainPolicy = new X509ChainPolicy ((X509CertificateCollection)(object)certs);
#if !MOBILE
chain.ChainPolicy.RevocationMode = revocation_mode;
#endif
for (int i = 1; i < certs.Count; i++) {
chain.ChainPolicy.ExtraStore.Add (certs [i]);
}
return chain;
}

View File

@@ -1 +1 @@
0f1c977a71d57169dc91c54c8baa329f65d18b38
b41d204ace8747f8b745660642c23d3998baf913

View File

@@ -12,12 +12,20 @@ using System.Collections.Generic;
namespace System.Net {
/*
* The idea behind this API was to let the application filter the set of cipher suites received / send to
* the remote side. This concept does not any longer work with the new native implementations.
*/
[Obsolete ("This API is no longer supported.")]
public delegate IEnumerable<string> CipherSuitesCallback (SecurityProtocolType protocol, IEnumerable<string> allCiphers);
public partial class ServicePointManager {
[Obsolete ("This API is no longer supported.", true)]
public static CipherSuitesCallback ClientCipherSuitesCallback { get; set; }
[Obsolete ("This API is no longer supported.", true)]
public static CipherSuitesCallback ServerCipherSuitesCallback { get; set; }
}
}
}

View File

@@ -154,7 +154,8 @@ namespace System.Security.Cryptography.X509Certificates {
certArray = FromIntPtrs (secCerts);
host = CFStringCreateWithCharacters (IntPtr.Zero, hostName, (IntPtr) hostName.Length);
if (!string.IsNullOrEmpty (hostName))
host = CFStringCreateWithCharacters (IntPtr.Zero, hostName, (IntPtr) hostName.Length);
sslsecpolicy = SecPolicyCreateSSL (true, host);
int code = SecTrustCreateWithCertificates (certArray, sslsecpolicy, out sectrust);

View File

@@ -35,7 +35,8 @@ namespace System.Security.Cryptography.X509Certificates {
private OidCollection apps;
private OidCollection cert;
private X509Certificate2Collection store;
private X509CertificateCollection store;
private X509Certificate2Collection store2;
private X509RevocationFlag rflag;
private X509RevocationMode mode;
private TimeSpan timeout;
@@ -49,6 +50,24 @@ namespace System.Security.Cryptography.X509Certificates {
Reset ();
}
/*
* Lazy-init ExtraStore from X509CertificateCollection.
* This is called from Mono.Net.Security.SystemCertificateValidator.CreateX509Chain.
*
* AppleTLS supports a lazily-initialized X509Certificate, but not X509Certificate2 so
* we need to fall-back to using Mono.Security.X509 whenever we need an X509Certificate2.
* To avoid unnecessary fallbacks, the private Mono.Net.Security APIs use X509Certificate
* instead of X509Certificate2.
*
* Since 'ExtraStore' returns X509Certificate2Collection, we need to convert these to
* X509Certificate2.
*/
internal X509ChainPolicy (X509CertificateCollection store)
{
this.store = store;
Reset ();
}
// properties
public OidCollection ApplicationPolicy {
@@ -60,7 +79,18 @@ namespace System.Security.Cryptography.X509Certificates {
}
public X509Certificate2Collection ExtraStore {
get { return store; }
get {
if (store2 != null)
return store2;
store2 = new X509Certificate2Collection ();
if (store != null) {
foreach (var cert in store) {
store2.Add (new X509Certificate2 (cert));
}
}
return store2;
}
}
public X509RevocationFlag RevocationFlag {
@@ -106,7 +136,7 @@ namespace System.Security.Cryptography.X509Certificates {
{
apps = new OidCollection ();
cert = new OidCollection ();
store = new X509Certificate2Collection ();
store2 = null;
rflag = X509RevocationFlag.ExcludeRoot;
mode = X509RevocationMode.Online;
timeout = TimeSpan.Zero;

View File

@@ -247,6 +247,7 @@ System.Net.Sockets/MulticastOptionTest.cs
System.Net.Sockets/NetworkStreamTest.cs
System.Net.Sockets/TcpClientTest.cs
System.Net.Sockets/TcpListenerTest.cs
System.Net.Sockets/SocketAcceptAsyncTest.cs
System.Net.Sockets/SocketTest.cs
System.Net.Sockets/SocketAsyncEventArgsTest.cs
System.Net.Sockets/SocketConnectAsyncTest.cs

View File

@@ -93,80 +93,6 @@ public class SslStreamTest {
}
}
[Test]
public void ClientCipherSuitesCallback ()
{
try {
ServicePointManager.ClientCipherSuitesCallback += (SecurityProtocolType p, IEnumerable<string> allCiphers) => {
string prefix = p == SecurityProtocolType.Tls ? "TLS_" : "SSL_";
return new List<string> { prefix + "RSA_WITH_AES_128_CBC_SHA" };
};
// client will only offers AES 128 - that's fine since the server support it (and many more ciphers)
AuthenticateClientAndServer_ClientSendsNoData ();
}
finally {
ServicePointManager.ClientCipherSuitesCallback = null;
}
}
[Test]
public void ServerCipherSuitesCallback ()
{
try {
ServicePointManager.ServerCipherSuitesCallback += (SecurityProtocolType p, IEnumerable<string> allCiphers) => {
string prefix = p == SecurityProtocolType.Tls ? "TLS_" : "SSL_";
return new List<string> { prefix + "RSA_WITH_AES_256_CBC_SHA" };
};
// server only accept AES 256 - that's fine since the client support it (and many more ciphers)
AuthenticateClientAndServer_ClientSendsNoData ();
}
finally {
ServicePointManager.ServerCipherSuitesCallback = null;
}
}
[Test]
public void CipherSuitesCallbacks ()
{
try {
ServicePointManager.ClientCipherSuitesCallback += (SecurityProtocolType p, IEnumerable<string> allCiphers) => {
string prefix = p == SecurityProtocolType.Tls ? "TLS_" : "SSL_";
return new List<string> { prefix + "RSA_WITH_AES_128_CBC_SHA", prefix + "RSA_WITH_AES_256_CBC_SHA" };
};
ServicePointManager.ServerCipherSuitesCallback += (SecurityProtocolType p, IEnumerable<string> allCiphers) => {
string prefix = p == SecurityProtocolType.Tls ? "TLS_" : "SSL_";
return new List<string> { prefix + "RSA_WITH_AES_128_CBC_SHA", prefix + "RSA_WITH_AES_256_CBC_SHA" };
};
// both client and server supports AES (128 and 256) - server will select 128 (first choice)
AuthenticateClientAndServer_ClientSendsNoData ();
}
finally {
ServicePointManager.ClientCipherSuitesCallback = null;
ServicePointManager.ServerCipherSuitesCallback = null;
}
}
[Test]
public void MismatchedCipherSuites ()
{
try {
ServicePointManager.ClientCipherSuitesCallback += (SecurityProtocolType p, IEnumerable<string> allCiphers) => {
string prefix = p == SecurityProtocolType.Tls ? "TLS_" : "SSL_";
return new List<string> { prefix + "RSA_WITH_AES_128_CBC_SHA" };
};
ServicePointManager.ServerCipherSuitesCallback += (SecurityProtocolType p, IEnumerable<string> allCiphers) => {
string prefix = p == SecurityProtocolType.Tls ? "TLS_" : "SSL_";
return new List<string> { prefix + "RSA_WITH_AES_256_CBC_SHA" };
};
// mismatch! server will refuse and send back an alert
AuthenticateClientAndServer (false, false);
}
finally {
ServicePointManager.ClientCipherSuitesCallback = null;
ServicePointManager.ServerCipherSuitesCallback = null;
}
}
private void StartClientAndAuthenticate (ClientServerState state,
IPEndPoint endPoint) {
try {

View File

@@ -0,0 +1,60 @@
using System.Threading;
using System.Net;
using System.Net.Sockets;
using NUnit.Framework;
namespace MonoTests.System.Net.Sockets
{
[TestFixture]
public class SocketAcceptAsyncTest
{
[Test]
public void AcceptAsyncShouldUseAcceptSocketFromEventArgs()
{
var readyEvent = new ManualResetEvent(false);
var mainEvent = new ManualResetEvent(false);
var listenSocket = new Socket(
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
var serverSocket = new Socket(
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
Socket acceptedSocket = null;
ThreadPool.QueueUserWorkItem(_ =>
{
listenSocket.Bind(new IPEndPoint(IPAddress.Loopback, 0));
listenSocket.Listen(1);
var asyncEventArgs = new SocketAsyncEventArgs {AcceptSocket = serverSocket};
asyncEventArgs.Completed += (s, e) =>
{
acceptedSocket = e.AcceptSocket;
mainEvent.Set();
};
readyEvent.Set();
if (listenSocket.AcceptAsync(asyncEventArgs))
return;
acceptedSocket = asyncEventArgs.AcceptSocket;
mainEvent.Set();
});
Assert.IsTrue(readyEvent.WaitOne(1500));
var clientSocket = new Socket(
AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
clientSocket.Connect(listenSocket.LocalEndPoint);
clientSocket.NoDelay = true;
Assert.IsTrue(mainEvent.WaitOne(1500));
Assert.AreEqual(serverSocket, acceptedSocket);
mainEvent.Reset();
if (acceptedSocket != null)
acceptedSocket.Close();
listenSocket.Close();
readyEvent.Close();
mainEvent.Close();
}
}
}

View File

@@ -7,13 +7,6 @@
// (C) 2001 Mads Pultz
// (C) 2003 Martin Willemoes Hansen
//
// This test assumes the following:
// 1) The following Internet sites exist:
// www.go-mono.com with IP address 64.14.94.188
// info.diku.dk with IP address 130.225.96.4
// 2) The following DNS name does not exist:
// www.hopefullydoesnotexist.dk
//
using System;
using System.Collections;
@@ -28,12 +21,12 @@ namespace MonoTests.System.Net
[TestFixture]
public class DnsTest
{
private String site1Name = "jenkins.mono-project.com",
site1Dot = "162.253.133.196",
site2Name = "info.diku.dk",
site2Dot = "130.225.96.4",
private String site1Name = "google-public-dns-a.google.com",
site1Dot = "8.8.8.8",
site2Name = "google-public-dns-b.google.com",
site2Dot = "8.8.4.4",
noneExistingSite = "unlikely.xamarin.com";
private uint site1IP = 1852407392, site2IP = 2195808260; // Big-Endian
private uint site1IP = 134744072, site2IP = 134743044; // Big-Endian
[Test]
public void AsyncGetHostByName ()
@@ -44,7 +37,7 @@ namespace MonoTests.System.Net
IAsyncResult async = Dns.BeginGetHostByName (site1Name, null, null);
IPHostEntry entry = Dns.EndGetHostByName (async);
SubTestValidIPHostEntry (entry);
Assert.IsTrue (entry.HostName == "jenkins.mono-project.com");
Assert.IsTrue (entry.HostName == "google-public-dns-a.google.com");
}
void GetHostByNameCallback (IAsyncResult ar)
@@ -189,7 +182,7 @@ namespace MonoTests.System.Net
[Test]
public void GetHostByName ()
{
SubTestGetHostByName ("jenkins.mono-project.com", site1Dot);
SubTestGetHostByName (site1Name, site1Dot);
SubTestGetHostByName (site2Name, site2Dot);
try {
var entry = Dns.GetHostByName (noneExistingSite);

View File

@@ -148,34 +148,46 @@ namespace System.Security.Cryptography.X509Certificates
}
}
#if !MONOTOUCH && !XAMMAC
public static X509CertificateImpl Import (byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags)
static byte[] PEM (string type, byte[] data)
{
if (nativeHelper != null)
return nativeHelper.Import (rawData, password, keyStorageFlags);
string pem = Encoding.ASCII.GetString (data);
string header = String.Format ("-----BEGIN {0}-----", type);
string footer = String.Format ("-----END {0}-----", type);
int start = pem.IndexOf (header) + header.Length;
int end = pem.IndexOf (footer, start);
string base64 = pem.Substring (start, (end - start));
return Convert.FromBase64String (base64);
}
static byte[] ConvertData (byte[] data)
{
if (data == null || data.Length == 0)
return data;
// does it looks like PEM ?
if (data [0] != 0x30) {
try {
return PEM ("CERTIFICATE", data);
} catch {
// let the implementation take care of it.
}
}
return data;
}
#if !MONOTOUCH && !XAMMAC
static X509CertificateImpl Import (byte[] rawData)
{
MX.X509Certificate x509;
if (password == null) {
try {
x509 = new MX.X509Certificate (rawData);
} catch (Exception e) {
try {
x509 = new MX.X509Certificate (rawData);
} catch (Exception e) {
try {
x509 = ImportPkcs12 (rawData, null);
} catch {
string msg = Locale.GetText ("Unable to decode certificate.");
// inner exception is the original (not second) exception
throw new CryptographicException (msg, e);
}
}
} else {
// try PKCS#12
try {
x509 = ImportPkcs12 (rawData, password);
}
catch {
// it's possible to supply a (unrequired/unusued) password
// fix bug #79028
x509 = new MX.X509Certificate (rawData);
x509 = ImportPkcs12 (rawData, null);
} catch {
string msg = Locale.GetText ("Unable to decode certificate.");
// inner exception is the original (not second) exception
throw new CryptographicException (msg, e);
}
}
@@ -183,6 +195,26 @@ namespace System.Security.Cryptography.X509Certificates
}
#endif
public static X509CertificateImpl Import (byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags)
{
if (password == null) {
rawData = ConvertData (rawData);
return Import (rawData);
}
MX.X509Certificate x509;
// try PKCS#12
try {
x509 = ImportPkcs12 (rawData, password);
} catch {
// it's possible to supply a (unrequired/unusued) password
// fix bug #79028
x509 = new MX.X509Certificate (rawData);
}
return new X509CertificateImplMono (x509);
}
public static byte[] Export (X509CertificateImpl impl, X509ContentType contentType, byte[] password)
{
ThrowIfContextInvalid (impl);

View File

@@ -1671,6 +1671,9 @@ namespace MonoTests.System.IO
} catch (FileNotFoundException) {
// Only run this test on platforms where /dev/zero exists
Assert.Ignore();
} catch (DirectoryNotFoundException) {
// Only run this test on platforms where /dev exists
Assert.Ignore();
}
// this shouldn't throw

View File

@@ -304,7 +304,7 @@ namespace MonoTests.System.Threading
});
}
Assert.IsTrue (ce.Wait (1000), "#1");
Assert.IsTrue (ce.Wait (10000), "#1");
}
}
}

View File

@@ -103,7 +103,7 @@ namespace MonoTests.System.Threading {
[Test] // bug #320950
public void TestDispose2 ()
{
Timer t = new Timer (o => Callback (o), null, 10, 10);
Timer t = new Timer (o => DoNothing (o), null, 10, 10);
t.Dispose ();
t.Dispose ();
}

View File

@@ -1 +1 @@
cda5f1e52d7ff05ac3c67c95adb635880bcd8928
5203fe1002a11476d61e6876fd7bfce0d3bdd618

View File

@@ -1 +1 @@
f28fbc2560c903ccf538f1f56b893a8ee0b9b7b0
f1a099fb8bb3184e5205e97ba95cf836dfe8cc55

View File

@@ -1 +1 @@
d75327e36d7b32dc9109603a62412b3e8aa159fe
0c4f173c3278c4f1e67d28260a84b3168b0cb207

View File

@@ -1 +1 @@
dd524703971ceb5b9e38a37927cbf400b8445a80
94fa7ed0e1fb060ea39ff108b58e4bf1c7169357

Some files were not shown because too many files have changed in this diff Show More