Browse Source

[Mono.Security]: Add MonoTlsProviderFactory.GetMonoSslStream(SslStream).

Martin Baulig 10 years ago
parent
commit
ebbf7640cc

+ 7 - 1
mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsProviderFactory.cs

@@ -25,8 +25,9 @@
 // THE SOFTWARE.
 using System;
 using System.Net;
-using Mono.Net.Security;
+using System.Net.Security;
 using System.Security.Cryptography.X509Certificates;
+using Mono.Net.Security;
 
 namespace Mono.Security.Interface
 {
@@ -97,6 +98,11 @@ namespace Mono.Security.Interface
 		{
 			return (HttpListener)NoReflectionHelper.CreateHttpListener (certificate, provider, settings);
 		}
+
+		public static IMonoSslStream GetMonoSslStream (SslStream stream)
+		{
+			return (IMonoSslStream)NoReflectionHelper.GetMonoSslStream (stream);
+		}
 	}
 }
 

+ 11 - 0
mcs/class/System/Mono.Net.Security/NoReflectionHelper.cs

@@ -38,6 +38,7 @@ using System.Security.Cryptography.X509Certificates;
 
 using System;
 using System.Net;
+using System.Net.Security;
 
 namespace Mono.Net.Security
 {
@@ -109,5 +110,15 @@ namespace Mono.Net.Security
 			throw new NotSupportedException ();
 			#endif
 		}
+
+		internal static object GetMonoSslStream (SslStream stream)
+		{
+			#if SECURITY_DEP
+			return stream.Impl;
+			#else
+			throw new NotSupportedException ();
+			#endif
+		}
+
 	}
 }

+ 10 - 1
mcs/class/System/System.Net.Security/SslStream.cs

@@ -24,7 +24,8 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 // THE SOFTWARE.
 
-#if SECURITY_DEP && !MONO_FEATURE_NEW_TLS
+#if !MONO_FEATURE_NEW_TLS
+#if SECURITY_DEP
 
 #if MONO_X509_ALIAS
 extern alias PrebuiltSystem;
@@ -405,5 +406,13 @@ namespace System.Net.Security
 		}
 	}
 }
+#else // !SECURITY_DEP
+namespace System.Net.Security
+{
+	public class SslStream
+	{
+	}
+}
+#endif
 
 #endif