Imported Upstream version 6.8.0.73

Former-commit-id: d18deab1b47cfd3ad8cba82b3f37d00eec2170af
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-12-10 18:00:56 +00:00
parent bceda29824
commit 73ee7591e8
1043 changed files with 16271 additions and 22080 deletions

View File

@@ -70,7 +70,7 @@ namespace Mono.Net.Security
*
*/
internal static MSI.MonoTlsProvider GetProviderInternal ()
internal static MobileTlsProvider GetProviderInternal ()
{
lock (locker) {
InitializeInternal ();
@@ -88,7 +88,7 @@ namespace Mono.Net.Security
InitializeProviderRegistration ();
MSI.MonoTlsProvider provider;
MobileTlsProvider provider;
try {
provider = CreateDefaultProviderImpl ();
} catch (Exception ex) {
@@ -123,18 +123,18 @@ namespace Mono.Net.Security
static object locker = new object ();
static bool initialized;
static MSI.MonoTlsProvider defaultProvider;
static MobileTlsProvider defaultProvider;
/*
* @providerRegistration maps provider names to a tuple containing its ID and full type name.
* On non-reflection enabled systems (such as XI and XM), we can use the Guid to uniquely
* identify the provider.
*
* @providerCache maps the provider's Guid to the MSI.MonoTlsProvider instance.
* @providerCache maps the provider's Guid to the MobileTlsProvider instance.
*
*/
static Dictionary<string,Tuple<Guid,string>> providerRegistration;
static Dictionary<Guid,MSI.MonoTlsProvider> providerCache;
static Dictionary<Guid,MobileTlsProvider> providerCache;
#if !ONLY_APPLETLS && !MONOTOUCH && !XAMMAC
static Type LookupProviderType (string name, bool throwOnError)
@@ -155,7 +155,7 @@ namespace Mono.Net.Security
}
#endif
static MSI.MonoTlsProvider LookupProvider (string name, bool throwOnError)
static MobileTlsProvider LookupProvider (string name, bool throwOnError)
{
lock (locker) {
InitializeProviderRegistration ();
@@ -167,7 +167,7 @@ namespace Mono.Net.Security
}
// Check cache before doing the reflection lookup.
MSI.MonoTlsProvider provider;
MobileTlsProvider provider;
if (providerCache.TryGetValue (entry.Item1, out provider))
return provider;
@@ -177,7 +177,7 @@ namespace Mono.Net.Security
throw new NotSupportedException (string.Format ("Could not find TLS Provider: `{0}'.", entry.Item2));
try {
provider = (MSI.MonoTlsProvider)Activator.CreateInstance (type, true);
provider = (MobileTlsProvider)Activator.CreateInstance (type, true);
} catch (Exception ex) {
throw new NotSupportedException (string.Format ("Unable to instantiate TLS Provider `{0}'.", type), ex);
}
@@ -214,7 +214,6 @@ namespace Mono.Net.Security
internal static readonly Guid AppleTlsId = new Guid ("981af8af-a3a3-419a-9f01-a518e3a17c1c");
internal static readonly Guid BtlsId = new Guid ("432d18c9-9348-4b90-bfbf-9f2a10e1f15b");
internal static readonly Guid LegacyId = new Guid ("809e77d5-56cc-4da8-b9f0-45e65ba9cceb");
static void InitializeProviderRegistration ()
{
@@ -225,7 +224,7 @@ namespace Mono.Net.Security
InitializeDebug ();
providerRegistration = new Dictionary<string,Tuple<Guid,string>> ();
providerCache = new Dictionary<Guid,MSI.MonoTlsProvider> ();
providerCache = new Dictionary<Guid,MobileTlsProvider> ();
PopulateProviders ();
}
@@ -238,34 +237,31 @@ namespace Mono.Net.Security
var appleTlsEntry = new Tuple<Guid,String> (AppleTlsId, typeof (Mono.AppleTls.AppleTlsProvider).FullName);
providerRegistration.Add ("default", appleTlsEntry);
providerRegistration.Add ("legacy", appleTlsEntry);
providerRegistration.Add ("apple", appleTlsEntry);
}
#elif MONODROID
// TODO: Should be redundant
static void PopulateProviders ()
{
var legacyEntry = new Tuple<Guid,String> (LegacyId, typeof (Mono.Net.Security.LegacyTlsProvider).FullName);
providerRegistration.Add ("legacy", legacyEntry);
#if MONO_FEATURE_BTLS
#if MONO_FEATURE_BTLS
var btlsEntry = new Tuple<Guid,String> (BtlsId, typeof (Mono.Btls.MonoBtlsProvider).FullName);
if (btlsEntry != null)
providerRegistration.Add ("default", btlsEntry);
else
#endif
providerRegistration.Add ("default", legacyEntry);
providerRegistration.Add ("default", btlsEntry);
providerRegistration.Add ("legacy", btlsEntry);
providerRegistration.Add ("btls", btlsEntry);
#endif
}
#else
static void PopulateProviders ()
{
#if MONO_FEATURE_APPLETLS
var appleTlsEntry = new Tuple<Guid,String> (AppleTlsId, typeof (Mono.AppleTls.AppleTlsProvider).FullName);
#endif
var legacyEntry = new Tuple<Guid,String> (LegacyId, typeof (Mono.Net.Security.LegacyTlsProvider).FullName);
providerRegistration.Add ("legacy", legacyEntry);
Tuple<Guid,String> appleTlsEntry = null;
Tuple<Guid,String> btlsEntry = null;
#if MONO_FEATURE_APPLETLS
appleTlsEntry = new Tuple<Guid,String> (AppleTlsId, typeof (Mono.AppleTls.AppleTlsProvider).FullName);
providerRegistration.Add ("apple", appleTlsEntry);
#endif
#if MONO_FEATURE_BTLS
if (IsBtlsSupported ()) {
btlsEntry = new Tuple<Guid,String> (BtlsId, typeof (Mono.Btls.MonoBtlsProvider).FullName);
@@ -273,21 +269,11 @@ namespace Mono.Net.Security
}
#endif
#if MONO_FEATURE_APPLETLS
if (Platform.IsMacOS)
providerRegistration.Add ("default", appleTlsEntry);
else
#endif
#if MONO_FEATURE_BTLS
if (btlsEntry != null)
providerRegistration.Add ("default", btlsEntry);
else
#endif
providerRegistration.Add ("default", legacyEntry);
#if MONO_FEATURE_APPLETLS
providerRegistration.Add ("apple", appleTlsEntry);
#endif
var defaultEntry = appleTlsEntry ?? btlsEntry;
if (defaultEntry != null) {
providerRegistration.Add ("default", defaultEntry);
providerRegistration.Add ("legacy", defaultEntry);
}
}
#endif
@@ -297,24 +283,22 @@ namespace Mono.Net.Security
internal extern static bool IsBtlsSupported ();
#endif
static MSI.MonoTlsProvider CreateDefaultProviderImpl ()
static MobileTlsProvider CreateDefaultProviderImpl ()
{
#if MONODROID
MSI.MonoTlsProvider provider = null;
var type = Environment.GetEnvironmentVariable ("XA_TLS_PROVIDER");
switch (type) {
#if MONO_FEATURE_BTLS
case null:
case "default":
case "legacy":
return new LegacyTlsProvider ();
#if MONO_FEATURE_BTLS
case "btls":
if (!IsBtlsSupported ())
throw new NotSupportedException ("BTLS in not supported!");
return new MonoBtlsProvider ();
#endif
default:
throw new NotSupportedException (string.Format ("Invalid TLS Provider: `{0}'.", provider));
throw new NotSupportedException ($"Invalid TLS Provider: `{type}'.");
}
#elif ONLY_APPLETLS || MONOTOUCH || XAMMAC
@@ -326,6 +310,7 @@ namespace Mono.Net.Security
switch (type) {
case "default":
case "legacy":
#if MONO_FEATURE_APPLETLS
if (Platform.IsMacOS)
goto case "apple";
@@ -334,7 +319,7 @@ namespace Mono.Net.Security
if (IsBtlsSupported ())
goto case "btls";
#endif
goto case "legacy";
throw new NotSupportedException ("TLS Support not available.");
#if MONO_FEATURE_APPLETLS
case "apple":
return new AppleTlsProvider ();
@@ -343,8 +328,6 @@ namespace Mono.Net.Security
case "btls":
return new MonoBtlsProvider ();
#endif
case "legacy":
return new Mono.Net.Security.LegacyTlsProvider ();
}
return LookupProvider (type, true);
@@ -359,13 +342,9 @@ namespace Mono.Net.Security
* Mono.Security.dll provides a public wrapper around these.
*/
internal static MSI.MonoTlsProvider GetProvider ()
internal static MobileTlsProvider GetProvider ()
{
var provider = GetProviderInternal ();
if (provider == null)
throw new NotSupportedException ("No TLS Provider available.");
return provider;
return GetProviderInternal ();
}
internal static bool IsProviderSupported (string name)
@@ -376,7 +355,7 @@ namespace Mono.Net.Security
}
}
internal static MSI.MonoTlsProvider GetProvider (string name)
internal static MobileTlsProvider GetProvider (string name)
{
return LookupProvider (name, false);
}