From 9437553e545f57443ccc33fe4129cbb6ac94f832 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Thu, 29 Sep 2016 00:53:03 +0200 Subject: [PATCH] [System]: Rename MonoLegacyTlsProvider into LegacyTlsProvider. (#3666) LegacyTlsProvider now lives in the 'Mono.Net.Security' namespace (previously 'Mono.Net.Security.Private') and derives directly from the public 'Mono.Security.Interface.MonoTlsProvider'. This allows it to be used by products, for instance replacing xamarin-macios/src/Security/Tls/OldTlsProvider.cs. The idea is to have all 'MonoTlsProvider' implementations inside System.dll and not access any of the private APIs from outside of it. --- ...noLegacyTlsProvider.cs => LegacyTlsProvider.cs} | 37 ++++++++++------------ .../MonoTlsProviderFactory.Droid.cs | 2 +- .../Mono.Net.Security/MonoTlsProviderFactory.cs | 4 +-- mcs/class/System/System.dll.sources | 2 +- mcs/class/System/mobile_System.dll.sources | 2 +- .../monotouch_watch_System.dll.exclude.sources | 2 +- 6 files changed, 22 insertions(+), 27 deletions(-) rename mcs/class/System/Mono.Net.Security/{MonoLegacyTlsProvider.cs => LegacyTlsProvider.cs} (71%) diff --git a/mcs/class/System/Mono.Net.Security/MonoLegacyTlsProvider.cs b/mcs/class/System/Mono.Net.Security/LegacyTlsProvider.cs similarity index 71% rename from mcs/class/System/Mono.Net.Security/MonoLegacyTlsProvider.cs rename to mcs/class/System/Mono.Net.Security/LegacyTlsProvider.cs index 78f4731fc7b..72996ded8e8 100644 --- a/mcs/class/System/Mono.Net.Security/MonoLegacyTlsProvider.cs +++ b/mcs/class/System/Mono.Net.Security/LegacyTlsProvider.cs @@ -1,5 +1,5 @@ // -// MonoLegacyTlsProvider.cs +// LegacyTlsProvider.cs // // Author: // Martin Baulig @@ -28,13 +28,10 @@ extern alias MonoSecurity; #endif -using XHttpWebRequest = System.Net.HttpWebRequest; -using XSslProtocols = System.Security.Authentication.SslProtocols; - #if MONO_SECURITY_ALIAS -using MonoSecurity::Mono.Security.Interface; +using MSI = MonoSecurity::Mono.Security.Interface; #else -using Mono.Security.Interface; +using MSI = Mono.Security.Interface; #endif using System; @@ -42,13 +39,14 @@ using System.IO; using System.Net; using System.Net.Security; using System.Security.Cryptography.X509Certificates; +using System.Security.Authentication; -namespace Mono.Net.Security.Private +namespace Mono.Net.Security { /* * Strictly private - do not use outside the Mono.Net.Security directory. */ - class MonoLegacyTlsProvider : MonoTlsProviderImpl + class LegacyTlsProvider : MSI.MonoTlsProvider { static readonly Guid id = new Guid ("809e77d5-56cc-4da8-b9f0-45e65ba9cceb"); @@ -60,10 +58,6 @@ namespace Mono.Net.Security.Private get { return "legacy"; } } - public MonoTlsProvider Provider { - get { return this; } - } - public override bool SupportsSslStream { get { return true; } } @@ -80,22 +74,23 @@ namespace Mono.Net.Security.Private get { return false; } } - public override XSslProtocols SupportedProtocols { - get { return XSslProtocols.Ssl3 | XSslProtocols.Tls; } + public override SslProtocols SupportedProtocols { + get { return SslProtocols.Tls; } } - protected override IMonoSslStream CreateSslStreamImpl ( + public override MSI.IMonoSslStream CreateSslStream ( Stream innerStream, bool leaveInnerStreamOpen, - MonoTlsSettings settings) + MSI.MonoTlsSettings settings = null) { - return new LegacySslStream (innerStream, leaveInnerStreamOpen, this, settings); + var impl = new Private.LegacySslStream (innerStream, leaveInnerStreamOpen, this, settings); + return new Private.MonoSslStreamImpl (impl); } - protected override IMonoTlsContext CreateTlsContextImpl ( - string hostname, bool serverMode, TlsProtocols protocolFlags, + internal override MSI.IMonoTlsContext CreateTlsContext ( + string hostname, bool serverMode, MSI.TlsProtocols protocolFlags, X509Certificate serverCertificate, X509CertificateCollection clientCertificates, - bool remoteCertRequired, MonoEncryptionPolicy encryptionPolicy, - MonoTlsSettings settings) + bool remoteCertRequired, MSI.MonoEncryptionPolicy encryptionPolicy, + MSI.MonoTlsSettings settings) { throw new NotSupportedException (); } diff --git a/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.Droid.cs b/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.Droid.cs index 72390bcdd11..7ba425257f5 100644 --- a/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.Droid.cs +++ b/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.Droid.cs @@ -18,7 +18,7 @@ namespace Mono.Net.Security case null: case "default": case "legacy": - return new Private.MonoLegacyTlsProvider (); + return new LegacyTlsProvider (); case "btls": #if HAVE_BTLS if (!MonoBtlsProvider.IsSupported ()) diff --git a/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs b/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs index 742a7286ab6..34d64334c15 100644 --- a/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs +++ b/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs @@ -155,7 +155,7 @@ namespace Mono.Net.Security if (providerRegistration != null) return; providerRegistration = new Dictionary (); - providerRegistration.Add ("legacy", "Mono.Net.Security.Private.MonoLegacyTlsProvider"); + providerRegistration.Add ("legacy", "Mono.Net.Security.LegacyTlsProvider"); #if HAVE_BTLS if (Mono.Btls.MonoBtlsProvider.IsSupported ()) providerRegistration.Add ("btls", "Mono.Btls.MonoBtlsProvider"); @@ -183,7 +183,7 @@ namespace Mono.Net.Security if (provider != null) return provider; - return new Private.MonoLegacyTlsProvider (); + return new LegacyTlsProvider (); } #endif diff --git a/mcs/class/System/System.dll.sources b/mcs/class/System/System.dll.sources index a878a5a7055..b6ce5073d73 100644 --- a/mcs/class/System/System.dll.sources +++ b/mcs/class/System/System.dll.sources @@ -544,7 +544,7 @@ Mono.Net.Security/IMonoSslStream.cs Mono.Net.Security/LegacySslStream.cs Mono.Net.Security/MobileAuthenticatedStream.cs Mono.Net.Security/MobileTlsContext.cs -Mono.Net.Security/MonoLegacyTlsProvider.cs +Mono.Net.Security/LegacyTlsProvider.cs Mono.Net.Security/MonoSslStreamImpl.cs Mono.Net.Security/MonoSslStreamWrapper.cs Mono.Net.Security/MonoTlsProviderFactory.cs diff --git a/mcs/class/System/mobile_System.dll.sources b/mcs/class/System/mobile_System.dll.sources index f9b97de0764..0bced0469ad 100644 --- a/mcs/class/System/mobile_System.dll.sources +++ b/mcs/class/System/mobile_System.dll.sources @@ -292,7 +292,7 @@ Mono.Net.Security/IMonoSslStream.cs Mono.Net.Security/LegacySslStream.cs Mono.Net.Security/MobileAuthenticatedStream.cs Mono.Net.Security/MobileTlsContext.cs -Mono.Net.Security/MonoLegacyTlsProvider.cs +Mono.Net.Security/LegacyTlsProvider.cs Mono.Net.Security/MonoSslStreamImpl.cs Mono.Net.Security/MonoSslStreamWrapper.cs Mono.Net.Security/MonoTlsProviderFactory.cs diff --git a/mcs/class/System/monotouch_watch_System.dll.exclude.sources b/mcs/class/System/monotouch_watch_System.dll.exclude.sources index ce4674bcac2..0138e11713a 100644 --- a/mcs/class/System/monotouch_watch_System.dll.exclude.sources +++ b/mcs/class/System/monotouch_watch_System.dll.exclude.sources @@ -1,5 +1,5 @@ Mono.Net.Security/LegacySslStream.cs -Mono.Net.Security/MonoLegacyTlsProvider.cs +Mono.Net.Security/LegacyTlsProvider.cs System.Net.Mail/SmtpClient.cs System.Net.Sockets/TcpClient.cs System.Net.Sockets/TcpListener.cs -- 2.11.4.GIT