diff options
Diffstat (limited to 'mcs/class/System')
5 files changed, 32 insertions, 36 deletions
diff --git a/mcs/class/System/Assembly/AssemblyInfo.cs b/mcs/class/System/Assembly/AssemblyInfo.cs index 4f0d50bf065..a7651da891f 100644 --- a/mcs/class/System/Assembly/AssemblyInfo.cs +++ b/mcs/class/System/Assembly/AssemblyInfo.cs @@ -80,4 +80,6 @@ using System.Runtime.InteropServices; [assembly: InternalsVisibleTo ("Mono.Security.Providers.NewSystemSource, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")] [assembly: InternalsVisibleTo ("Mono.Security.Providers.OldTls, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")] + [assembly: InternalsVisibleTo ("Mono.Security.Providers.NewTls, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")] + [assembly: InternalsVisibleTo ("Mono.Security.Providers.DotNet, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")] [assembly: InternalsVisibleTo ("Mono.Security, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")] diff --git a/mcs/class/System/Mono.Net.Security/MonoDefaultTlsProvider.cs b/mcs/class/System/Mono.Net.Security/MonoDefaultTlsProvider.cs index c39b2144781..d6f6e5296f4 100644 --- a/mcs/class/System/Mono.Net.Security/MonoDefaultTlsProvider.cs +++ b/mcs/class/System/Mono.Net.Security/MonoDefaultTlsProvider.cs @@ -86,7 +86,7 @@ namespace Mono.Net.Security.Private get { return false; } } - public override bool SupportsTlsContext { + internal override bool SupportsTlsContext { get { return false; } } diff --git a/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs b/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs index 85023644aee..f2cf321677d 100644 --- a/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs +++ b/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs @@ -134,25 +134,35 @@ namespace Mono.Net.Security #if SECURITY_DEP && !MONO_FEATURE_NEW_SYSTEM_SOURCE -#if !MOBILE static Dictionary<string,string> providerRegistration; - internal static void RegisterProvider (string name, string type) + static Type LookupProviderType (string name, bool throwOnError) { lock (locker) { InitializeProviderRegistration (); - providerRegistration.Add (name, type); + string typeName; + if (!providerRegistration.TryGetValue (name, out typeName)) { + if (throwOnError) + throw new NotSupportedException (string.Format ("No such TLS Provider: `{0}'.", name)); + return null; + } + var type = Type.GetType (typeName, false); + if (type == null && throwOnError) + throw new NotSupportedException (string.Format ("Could not find TLS Provider: `{0}'.", typeName)); + return type; } } - static string LookupProvider (string name) + static MSI.MonoTlsProvider LookupProvider (string name, bool throwOnError) { - lock (locker) { - InitializeProviderRegistration (); - string type; - if (!providerRegistration.TryGetValue (name, out type)) - type = null; - return type; + var type = LookupProviderType (name, throwOnError); + if (type == null) + return null; + + try { + return (MSI.MonoTlsProvider)Activator.CreateInstance (type); + } catch (Exception ex) { + throw new NotSupportedException (string.Format ("Unable to instantiate TLS Provider `{0}'.", type), ex); } } @@ -162,11 +172,12 @@ namespace Mono.Net.Security if (providerRegistration != null) return; providerRegistration = new Dictionary<string,string> (); - providerRegistration.Add ("newtls", "Mono.Security.Providers.NewTls.NewTlsProvider, Mono.Security.Providers.NewTls, Version=4.0.0.0, Culture=neutral, PublicKeyToken=84e3aee7225169c2"); - providerRegistration.Add ("oldtls", "Mono.Security.Providers.OldTls.OldTlsProvider, Mono.Security.Providers.OldTls, Version=4.0.0.0, Culture=neutral, PublicKeyToken=84e3aee7225169c2"); + providerRegistration.Add ("newtls", "Mono.Security.Providers.NewTls.NewTlsProvider, Mono.Security.Providers.NewTls, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756"); + providerRegistration.Add ("oldtls", "Mono.Security.Providers.OldTls.OldTlsProvider, Mono.Security.Providers.OldTls, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756"); } } +#if !MOBILE static IMonoTlsProvider TryDynamicLoad () { var variable = Environment.GetEnvironmentVariable ("MONO_TLS_PROVIDER"); @@ -176,25 +187,7 @@ namespace Mono.Net.Security if (string.Equals (variable, "default", StringComparison.OrdinalIgnoreCase)) return null; - string typeName; - if (variable.IndexOfAny (new char[] { ',', '.', '=' }) > 0) { - typeName = variable; - } else { - typeName = LookupProvider (variable); - if (typeName == null) - throw new NotSupportedException (string.Format ("No such TLS Provider: `{0}'.", typeName)); - } - - var type = Type.GetType (typeName, false); - if (type == null) - throw new NotSupportedException (string.Format ("Could not find TLS Provider: `{0}'.", typeName)); - - MSI.MonoTlsProvider provider; - try { - provider = (MSI.MonoTlsProvider)Activator.CreateInstance (type); - } catch (Exception ex) { - throw new NotSupportedException (string.Format ("Unable to instantiate TLS Provider `{0}'.", typeName), ex); - } + var provider = LookupProvider (variable, true); return new Private.MonoTlsProviderWrapper (provider); } @@ -245,9 +238,10 @@ namespace Mono.Net.Security } } - internal static void InstallProvider (MSI.MonoTlsProvider provider) + internal static void SetDefaultProvider (string name) { lock (locker) { + var provider = LookupProvider (name, true); currentProvider = new Private.MonoTlsProviderWrapper (provider); } } diff --git a/mcs/class/System/Mono.Net.Security/MonoTlsProviderImpl.cs b/mcs/class/System/Mono.Net.Security/MonoTlsProviderImpl.cs index 4216e5809f3..b0ae5d82c72 100644 --- a/mcs/class/System/Mono.Net.Security/MonoTlsProviderImpl.cs +++ b/mcs/class/System/Mono.Net.Security/MonoTlsProviderImpl.cs @@ -100,7 +100,7 @@ namespace Mono.Net.Security.Private bool remoteCertRequired, MSI.MonoEncryptionPolicy encryptionPolicy, MSI.MonoTlsSettings settings); - public override MSI.IMonoTlsContext CreateTlsContext ( + internal override MSI.IMonoTlsContext CreateTlsContext ( string hostname, bool serverMode, MSI.TlsProtocols protocolFlags, X509Certificate serverCertificate, XX509CertificateCollection clientCertificates, bool remoteCertRequired, MSI.MonoEncryptionPolicy encryptionPolicy, diff --git a/mcs/class/System/Mono.Net.Security/NoReflectionHelper.cs b/mcs/class/System/Mono.Net.Security/NoReflectionHelper.cs index f4ccac81cb0..a11fcec2c19 100644 --- a/mcs/class/System/Mono.Net.Security/NoReflectionHelper.cs +++ b/mcs/class/System/Mono.Net.Security/NoReflectionHelper.cs @@ -84,10 +84,10 @@ namespace Mono.Net.Security } } - internal static void InstallProvider (object provider) + internal static void SetDefaultProvider (string name) { #if SECURITY_DEP - MonoTlsProviderFactory.InstallProvider ((MSI.MonoTlsProvider)provider); + MonoTlsProviderFactory.SetDefaultProvider (name); #else throw new NotSupportedException (); #endif |