Imported Upstream version 5.18.0.161

Former-commit-id: 4db48158d3a35497b8f118ab21b5f08ac3d86d98
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-10-19 08:34:24 +00:00
parent 37fbf886a3
commit e19d552987
28702 changed files with 3868076 additions and 803 deletions

View File

@@ -85,6 +85,10 @@ ifdef ONLY_APPLETLS
LIB_MCS_FLAGS += -d:ONLY_APPLETLS
endif
ifdef MONO_FEATURE_APPLE_X509
LIB_MCS_FLAGS += -d:MONO_FEATURE_APPLE_X509
endif
ifndef PROFILE_DISABLE_BTLS
ifdef HAVE_BTLS

View File

@@ -33,7 +33,6 @@ using System.Runtime.InteropServices;
using System.Security.Cryptography.Apple;
using System.Security.Cryptography.X509Certificates;
using Microsoft.Win32.SafeHandles;
using Mono.Net;
namespace Mono.AppleTls
{
@@ -56,7 +55,7 @@ namespace Mono.AppleTls
if (Interlocked.CompareExchange (ref initialized, 1, 0) != 0)
return;
var handle = CFObject.dlopen (AppleTlsContext.SecurityLibrary, 0);
var handle = CFObject.dlopen (SecurityLibrary, 0);
if (handle == IntPtr.Zero)
return;
@@ -93,7 +92,7 @@ namespace Mono.AppleTls
}
}
[DllImport (AppleTlsContext.SecurityLibrary)]
[DllImport (SecurityLibrary)]
extern static SecStatusCode SecPKCS12Import (IntPtr pkcs12_data, IntPtr options, out IntPtr items);
static SecStatusCode ImportPkcs12 (byte[] buffer, CFDictionary options, out CFDictionary[] array)
@@ -134,7 +133,7 @@ namespace Mono.AppleTls
return identity ?? new SafeSecIdentityHandle ();
}
[DllImport (AppleTlsContext.SecurityLibrary)]
[DllImport (SecurityLibrary)]
extern static SecStatusCode SecItemCopyMatching (/* CFDictionaryRef */ IntPtr query, /* CFTypeRef* */ out IntPtr result);
public static SafeSecIdentityHandle FindIdentity (SafeSecCertificateHandle certificate, bool throwOnError = false)

View File

@@ -33,13 +33,14 @@ using System.Runtime.InteropServices;
using System.Security.Cryptography.Apple;
using System.Security.Cryptography.X509Certificates;
using Microsoft.Win32.SafeHandles;
using Mono.Net;
namespace Mono.AppleTls
{
static partial class MonoCertificatePal
{
[DllImport (AppleTlsContext.SecurityLibrary)]
const string SecurityLibrary = OSX509Certificates.SecurityLibrary;
[DllImport (SecurityLibrary)]
extern static IntPtr SecCertificateCreateWithData (IntPtr allocator, IntPtr cfData);
public static SafeSecCertificateHandle FromOtherCertificate (X509Certificate certificate)
@@ -66,7 +67,7 @@ namespace Mono.AppleTls
}
}
[DllImport (AppleTlsContext.SecurityLibrary)]
[DllImport (SecurityLibrary)]
extern static IntPtr SecIdentityGetTypeID ();
public static bool IsSecIdentity (IntPtr ptr)
@@ -76,7 +77,7 @@ namespace Mono.AppleTls
return CFType.GetTypeID (ptr) == SecIdentityGetTypeID ();
}
[DllImport (AppleTlsContext.SecurityLibrary)]
[DllImport (SecurityLibrary)]
public extern static IntPtr SecKeyGetTypeID ();
public static bool IsSecKey (IntPtr ptr)
@@ -86,7 +87,7 @@ namespace Mono.AppleTls
return CFType.GetTypeID (ptr) == SecKeyGetTypeID ();
}
[DllImport (AppleTlsContext.SecurityLibrary)]
[DllImport (SecurityLibrary)]
extern static /* OSStatus */ SecStatusCode SecIdentityCopyCertificate (/* SecIdentityRef */ IntPtr identityRef, /* SecCertificateRef* */ out IntPtr certificateRef);
public static SafeSecCertificateHandle GetCertificate (SafeSecIdentityHandle identity)
@@ -99,7 +100,7 @@ namespace Mono.AppleTls
return new SafeSecCertificateHandle (cert, true);
}
[DllImport (AppleTlsContext.SecurityLibrary)]
[DllImport (SecurityLibrary)]
extern static IntPtr SecCertificateCopySubjectSummary (IntPtr cert);
public static string GetSubjectSummary (SafeSecCertificateHandle certificate)
@@ -117,7 +118,7 @@ namespace Mono.AppleTls
}
}
[DllImport (AppleTlsContext.SecurityLibrary)]
[DllImport (SecurityLibrary)]
extern static /* CFDataRef */ IntPtr SecCertificateCopyData (/* SecCertificateRef */ IntPtr cert);
public static byte[] GetRawData (SafeSecCertificateHandle certificate)

View File

@@ -26,7 +26,7 @@
using System.Runtime.InteropServices;
using System.Security.Cryptography.Apple;
using Microsoft.Win32.SafeHandles;
using Mono.Net;
using Mono;
namespace System.Security.Cryptography.X509Certificates
{

View File

@@ -26,7 +26,7 @@
using System.Runtime.InteropServices;
using System.Security.Cryptography.Apple;
using Microsoft.Win32.SafeHandles;
using Mono.Net;
using Mono;
namespace System.Security.Cryptography.X509Certificates
{

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,6 @@
Mono.AppleTls/Enums.cs
Mono.AppleTls/X509CertificateImplApple.cs
Mono.AppleTls/X509PalImpl.Apple.cs
Mono.AppleTls/MonoCertificatePal.cs
Mono.AppleTls/SafeHandles.Mono.cs

View File

@@ -2,13 +2,7 @@ Mono.AppleTls/AppleCertificateHelper.cs
Mono.AppleTls/AppleTlsContext.cs
Mono.AppleTls/AppleTlsProvider.cs
Mono.AppleTls/AppleTlsStream.cs
Mono.AppleTls/Enums.cs
Mono.AppleTls/SecureTransport.cs
Mono.AppleTls/Policy.cs
Mono.AppleTls/Trust.cs
Mono.AppleTls/SslConnection.cs
Mono.AppleTls/X509CertificateImplApple.cs
Mono.AppleTls/X509PalImpl.Apple.cs
Mono.AppleTls/MonoCertificatePal.cs
Mono.AppleTls/SafeHandles.Mono.cs

View File

@@ -191,6 +191,7 @@ System.Timers/ElapsedEventArgs.cs
System.Windows.Input/ICommand.cs
Mono/AppleTypes.cs
Mono/SystemCertificateProvider.cs
Mono/SystemDependencyProvider.cs
Mono/X509Pal.cs

View File

@@ -1,5 +1,6 @@
#include corefx.unix.sources
#include net_4_x_System.dll.sources
#include apple-certificates.sources
#include appletls.sources
Mono.AppleTls/MonoCertificatePal.OSX.cs

View File

@@ -1,4 +1,5 @@
#include mobile_System.dll.sources
#include apple-certificates.sources
#include appletls.sources
Mono.AppleTls/MonoCertificatePal.Mobile.cs

View File

@@ -1,4 +1,2 @@
#include common_networking.sources
#include appletls.sources
Mono.AppleTls/MonoCertificatePal.Mobile.cs
Mono.AppleTls/SafeHandles.cs

View File

@@ -1,4 +1,6 @@
#include monotouch_System.dll.sources
#include apple-certificates.sources
System.Net.Mail/SmtpClient.platformnotsupported.cs
System.Net.Security/SslStream.platformnotsupported.cs
System.Net.Sockets/TcpClient.platformnotsupported.cs

View File

@@ -1,4 +1,5 @@
#include mobile_System.dll.sources
#include apple-certificates.sources
#include appletls.sources
Mono.AppleTls/MonoCertificatePal.Mobile.cs

View File

@@ -105,6 +105,21 @@ namespace Mono {
[MethodImplAttribute (MethodImplOptions.InternalCall)]
static extern void SendMicrosoftTelemetry_internal (IntPtr payload, ulong portable_hash, ulong unportable_hash);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
static extern void WriteStateToFile_internal (IntPtr payload, ulong portable_hash, ulong unportable_hash);
static void
WriteStateToFile (Exception exc)
{
ulong portable_hash;
ulong unportable_hash;
string payload_str = ExceptionToState_internal (exc, out portable_hash, out unportable_hash);
using (var payload_chars = RuntimeMarshal.MarshalString (payload_str))
{
WriteStateToFile_internal (payload_chars.Value, portable_hash, unportable_hash);
}
}
static void SendMicrosoftTelemetry (string payload_str, ulong portable_hash, ulong unportable_hash)
{
if (RuntimeInformation.IsOSPlatform (OSPlatform.OSX)) {
@@ -150,5 +165,43 @@ namespace Mono {
}
#endif
[MethodImplAttribute (MethodImplOptions.InternalCall)]
static extern string DumpStateSingle_internal (out ulong portable_hash, out ulong unportable_hash);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
static extern string DumpStateTotal_internal (out ulong portable_hash, out ulong unportable_hash);
static Tuple<String, ulong, ulong>
DumpStateSingle ()
{
ulong portable_hash;
ulong unportable_hash;
string payload_str = DumpStateSingle_internal (out portable_hash, out unportable_hash);
return new Tuple<String, ulong, ulong> (payload_str, portable_hash, unportable_hash);
}
static Tuple<String, ulong, ulong>
DumpStateTotal ()
{
ulong portable_hash;
ulong unportable_hash;
string payload_str = DumpStateTotal_internal (out portable_hash, out unportable_hash);
return new Tuple<String, ulong, ulong> (payload_str, portable_hash, unportable_hash);
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
static extern void RegisterReportingForNativeLib_internal (IntPtr modulePathSuffix, IntPtr moduleName);
static void RegisterReportingForNativeLib (string modulePathSuffix_str, string moduleName_str)
{
using (var modulePathSuffix_chars = RuntimeMarshal.MarshalString (modulePathSuffix_str))
using (var moduleName_chars = RuntimeMarshal.MarshalString (moduleName_str))
{
RegisterReportingForNativeLib_internal (modulePathSuffix_chars.Value, moduleName_chars.Value);
}
}
}
}

View File

@@ -243,7 +243,7 @@ namespace System
if (newError == null)
throw new ArgumentNullException ("newError");
stderr = newError;
stderr = TextWriter.Synchronized (newError);
}
[SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
@@ -252,7 +252,7 @@ namespace System
if (newIn == null)
throw new ArgumentNullException ("newIn");
stdin = newIn;
stdin = TextReader.Synchronized (newIn);
}
[SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
@@ -261,7 +261,7 @@ namespace System
if (newOut == null)
throw new ArgumentNullException ("newOut");
stdout = newOut;
stdout = TextWriter.Synchronized (newOut);
}
public static void Write (bool value)

View File

@@ -17,6 +17,8 @@ using System.Reflection;
using NUnit.Framework;
using System.Threading.Tasks;
namespace MonoTests.System
{
[TestFixture]
@@ -473,6 +475,102 @@ namespace MonoTests.System
// }
}
}
void DumpSingle ()
{
var monoType = Type.GetType ("Mono.Runtime", false);
var convert = monoType.GetMethod("DumpStateSingle", BindingFlags.NonPublic | BindingFlags.Static);
var output = (Tuple<String, ulong, ulong>) convert.Invoke(null, Array.Empty<object> ());
var dump = output.Item1;
var portable_hash = output.Item2;
var unportable_hash = output.Item3;
Assert.IsTrue (portable_hash != 0, "#1");
Assert.IsTrue (unportable_hash != 0, "#2");
Assert.IsTrue (dump.Length > 0, "#3");
}
void DumpTotal ()
{
var monoType = Type.GetType ("Mono.Runtime", false);
var convert = monoType.GetMethod("DumpStateTotal", BindingFlags.NonPublic | BindingFlags.Static);
var output = (Tuple<String, ulong, ulong>) convert.Invoke(null, Array.Empty<object> ());
var dump = output.Item1;
var portable_hash = output.Item2;
var unportable_hash = output.Item3;
Assert.IsTrue (portable_hash != 0, "#1");
Assert.IsTrue (unportable_hash != 0, "#2");
Assert.IsTrue (dump.Length > 0, "#3");
}
[Test]
[Category("NotOnWindows")]
public void DumpICallSingleOnce ()
{
DumpSingle ();
}
[Test]
[Category("NotOnWindows")]
public void DumpICallSingleConcurrent ()
{
// checks that self-dumping works in parallel, locklessly
int amt = 20;
var tasks = new Task [amt];
for (int i=0; i < amt; i++)
tasks [i] = Task.Run(() => DumpSingle ());
Task.WaitAll (tasks);
}
[Test]
[Category("NotOnWindows")]
public void DumpICallSingleAsync ()
{
// checks that dumping works in an async context
var t = Task.Run(() => DumpSingle ());
t.Wait ();
}
[Test]
[Category("NotOnWindows")]
public void DumpICallTotalOnce ()
{
DumpTotal ();
}
[Test]
[Category("NotOnWindows")]
public void DumpICallTotalRepeated ()
{
// checks that the state doesn't get broken with repeated use
DumpTotal ();
DumpTotal ();
DumpTotal ();
}
[Test]
[Category("NotOnWindows")]
public void DumpICallTotalAsync ()
{
// checks that dumping works in an async context
var t = Task.Run(() => DumpTotal ());
t.Wait ();
}
[Test]
[Category("NotOnWindows")]
public void DumpICallTotalConcurrent ()
{
int amt = 3;
var tasks = new Task [amt];
for (int i=0; i < amt; i++)
tasks [i] = Task.Run(() => DumpTotal ());
Task.WaitAll (tasks);
}
#endif
[Test]

View File

@@ -1 +0,0 @@
2cbb6a09884d85eab1fefb0e1b340f7d83c103de

View File

@@ -1 +0,0 @@
5cacb510426cd7ec0cfb12c5100ae077d5932e82

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