2014-08-13 10:39:27 +01:00
|
|
|
//
|
2016-02-22 11:00:01 -05:00
|
|
|
// SslStream.cs
|
2014-08-13 10:39:27 +01:00
|
|
|
//
|
2016-02-22 11:00:01 -05:00
|
|
|
// Author:
|
|
|
|
// Martin Baulig <martin.baulig@xamarin.com>
|
2014-08-13 10:39:27 +01:00
|
|
|
//
|
2016-02-22 11:00:01 -05:00
|
|
|
// Copyright (c) 2015 Xamarin, Inc.
|
2014-08-13 10:39:27 +01:00
|
|
|
//
|
2016-02-22 11:00:01 -05:00
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
// furnished to do so, subject to the following conditions:
|
2014-08-13 10:39:27 +01:00
|
|
|
//
|
2016-02-22 11:00:01 -05:00
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
2014-08-13 10:39:27 +01:00
|
|
|
//
|
2016-02-22 11:00:01 -05:00
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
// THE SOFTWARE.
|
|
|
|
|
2014-08-13 10:39:27 +01:00
|
|
|
#if SECURITY_DEP
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
#if MONO_SECURITY_ALIAS
|
2014-08-13 10:39:27 +01:00
|
|
|
extern alias MonoSecurity;
|
2016-02-22 11:00:01 -05:00
|
|
|
#endif
|
2014-08-13 10:39:27 +01:00
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
#if MONO_SECURITY_ALIAS
|
|
|
|
using MonoSecurity::Mono.Security.Interface;
|
|
|
|
#else
|
|
|
|
using Mono.Security.Interface;
|
|
|
|
#endif
|
2014-08-13 10:39:27 +01:00
|
|
|
|
|
|
|
using CipherAlgorithmType = System.Security.Authentication.CipherAlgorithmType;
|
|
|
|
using HashAlgorithmType = System.Security.Authentication.HashAlgorithmType;
|
|
|
|
using ExchangeAlgorithmType = System.Security.Authentication.ExchangeAlgorithmType;
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
using System.Net;
|
2016-02-22 11:00:01 -05:00
|
|
|
using System.Net.Security;
|
2014-08-13 10:39:27 +01:00
|
|
|
using System.Security.Authentication;
|
|
|
|
using System.Security.Cryptography.X509Certificates;
|
2016-02-22 11:00:01 -05:00
|
|
|
using System.Security.Permissions;
|
2014-08-13 10:39:27 +01:00
|
|
|
using System.Security.Principal;
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
using MNS = Mono.Net.Security;
|
|
|
|
|
|
|
|
namespace System.Net.Security
|
2014-08-13 10:39:27 +01:00
|
|
|
{
|
2016-02-22 11:00:01 -05:00
|
|
|
/*
|
|
|
|
* These two are defined by the referencesource; add them heere to make
|
|
|
|
* it easy to switch between the two implementations.
|
|
|
|
*/
|
|
|
|
|
|
|
|
internal delegate bool RemoteCertValidationCallback (
|
|
|
|
string host,
|
|
|
|
X509Certificate certificate,
|
|
|
|
X509Chain chain,
|
|
|
|
SslPolicyErrors sslPolicyErrors);
|
|
|
|
|
|
|
|
internal delegate X509Certificate LocalCertSelectionCallback (
|
|
|
|
string targetHost,
|
2016-08-03 10:59:49 +00:00
|
|
|
X509CertificateCollection localCertificates,
|
2016-02-22 11:00:01 -05:00
|
|
|
X509Certificate remoteCertificate,
|
|
|
|
string[] acceptableIssuers);
|
|
|
|
|
|
|
|
public class SslStream : AuthenticatedStream, MNS.IMonoSslStream
|
2014-08-13 10:39:27 +01:00
|
|
|
{
|
2016-02-22 11:00:01 -05:00
|
|
|
MonoTlsProvider provider;
|
|
|
|
IMonoSslStream impl;
|
2014-08-13 10:39:27 +01:00
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
internal IMonoSslStream Impl {
|
|
|
|
get {
|
|
|
|
CheckDisposed ();
|
|
|
|
return impl;
|
|
|
|
}
|
|
|
|
}
|
2014-08-13 10:39:27 +01:00
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
internal MonoTlsProvider Provider {
|
|
|
|
get {
|
|
|
|
CheckDisposed ();
|
|
|
|
return provider;
|
|
|
|
}
|
|
|
|
}
|
2014-08-13 10:39:27 +01:00
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
static MonoTlsProvider GetProvider ()
|
|
|
|
{
|
|
|
|
return MonoTlsProviderFactory.GetDefaultProvider ();
|
|
|
|
}
|
2014-08-13 10:39:27 +01:00
|
|
|
|
|
|
|
public SslStream (Stream innerStream)
|
|
|
|
: this (innerStream, false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public SslStream (Stream innerStream, bool leaveInnerStreamOpen)
|
|
|
|
: base (innerStream, leaveInnerStreamOpen)
|
|
|
|
{
|
2016-02-22 11:00:01 -05:00
|
|
|
provider = GetProvider ();
|
|
|
|
impl = provider.CreateSslStream (innerStream, leaveInnerStreamOpen);
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback)
|
|
|
|
: this (innerStream, leaveInnerStreamOpen, userCertificateValidationCallback, null)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback)
|
|
|
|
: base (innerStream, leaveInnerStreamOpen)
|
|
|
|
{
|
2016-02-22 11:00:01 -05:00
|
|
|
provider = GetProvider ();
|
|
|
|
var settings = MonoTlsSettings.CopyDefaultSettings ();
|
|
|
|
settings.RemoteCertificateValidationCallback = MNS.Private.CallbackHelpers.PublicToMono (userCertificateValidationCallback);
|
|
|
|
settings.ClientCertificateSelectionCallback = MNS.Private.CallbackHelpers.PublicToMono (userCertificateSelectionCallback);
|
|
|
|
impl = provider.CreateSslStream (innerStream, leaveInnerStreamOpen, settings);
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-08-23 13:20:38 +00:00
|
|
|
[MonoLimitation ("encryptionPolicy is ignored")]
|
|
|
|
public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback, EncryptionPolicy encryptionPolicy)
|
|
|
|
: this (innerStream, leaveInnerStreamOpen, userCertificateValidationCallback, userCertificateSelectionCallback)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
internal SslStream (Stream innerStream, bool leaveInnerStreamOpen, IMonoSslStream impl)
|
|
|
|
: base (innerStream, leaveInnerStreamOpen)
|
|
|
|
{
|
|
|
|
this.impl = impl;
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public virtual void AuthenticateAsClient (string targetHost)
|
|
|
|
{
|
|
|
|
Impl.AuthenticateAsClient (targetHost);
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-08-03 10:59:49 +00:00
|
|
|
public virtual void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
|
2016-02-22 11:00:01 -05:00
|
|
|
{
|
2016-08-03 10:59:49 +00:00
|
|
|
Impl.AuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
// [HostProtection (ExternalThreading=true)]
|
|
|
|
public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState)
|
|
|
|
{
|
|
|
|
return Impl.BeginAuthenticateAsClient (targetHost, asyncCallback, asyncState);
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
// [HostProtection (ExternalThreading=true)]
|
2016-08-03 10:59:49 +00:00
|
|
|
public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
|
2016-02-22 11:00:01 -05:00
|
|
|
{
|
2016-08-03 10:59:49 +00:00
|
|
|
return Impl.BeginAuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public virtual void EndAuthenticateAsClient (IAsyncResult asyncResult)
|
|
|
|
{
|
|
|
|
Impl.EndAuthenticateAsClient (asyncResult);
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public virtual void AuthenticateAsServer (X509Certificate serverCertificate)
|
|
|
|
{
|
|
|
|
Impl.AuthenticateAsServer (serverCertificate);
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public virtual void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
|
|
|
|
{
|
2016-08-03 10:59:49 +00:00
|
|
|
Impl.AuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
// [HostProtection (ExternalThreading=true)]
|
|
|
|
public virtual IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState)
|
|
|
|
{
|
|
|
|
return Impl.BeginAuthenticateAsServer (serverCertificate, asyncCallback, asyncState);
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public virtual IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
|
|
|
|
{
|
2016-08-03 10:59:49 +00:00
|
|
|
return Impl.BeginAuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public virtual void EndAuthenticateAsServer (IAsyncResult asyncResult)
|
|
|
|
{
|
|
|
|
Impl.EndAuthenticateAsServer (asyncResult);
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public TransportContext TransportContext {
|
2014-08-13 10:39:27 +01:00
|
|
|
get {
|
2016-02-22 11:00:01 -05:00
|
|
|
throw new NotSupportedException();
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
// [HostProtection (ExternalThreading=true)]
|
|
|
|
public virtual Task AuthenticateAsClientAsync (string targetHost)
|
|
|
|
{
|
|
|
|
return Impl.AuthenticateAsClientAsync (targetHost);
|
|
|
|
}
|
2014-08-13 10:39:27 +01:00
|
|
|
|
2016-08-03 10:59:49 +00:00
|
|
|
public virtual Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
|
2016-02-22 11:00:01 -05:00
|
|
|
{
|
2016-08-03 10:59:49 +00:00
|
|
|
return Impl.AuthenticateAsClientAsync (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public virtual Task AuthenticateAsServerAsync (X509Certificate serverCertificate)
|
|
|
|
{
|
|
|
|
return Impl.AuthenticateAsServerAsync (serverCertificate);
|
|
|
|
}
|
2014-08-13 10:39:27 +01:00
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public virtual Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
|
|
|
|
{
|
2016-08-03 10:59:49 +00:00
|
|
|
return Impl.AuthenticateAsServerAsync (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public override bool IsAuthenticated {
|
|
|
|
get { return Impl.IsAuthenticated; }
|
|
|
|
}
|
2014-08-13 10:39:27 +01:00
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public override bool IsMutuallyAuthenticated {
|
|
|
|
get { return Impl.IsMutuallyAuthenticated; }
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public override bool IsEncrypted {
|
|
|
|
get { return Impl.IsEncrypted; }
|
|
|
|
}
|
2014-08-13 10:39:27 +01:00
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public override bool IsSigned {
|
|
|
|
get { return Impl.IsSigned; }
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public override bool IsServer {
|
|
|
|
get { return Impl.IsServer; }
|
|
|
|
}
|
2014-08-13 10:39:27 +01:00
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public virtual SslProtocols SslProtocol {
|
|
|
|
get { return (SslProtocols)Impl.SslProtocol; }
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public virtual bool CheckCertRevocationStatus {
|
|
|
|
get { return Impl.CheckCertRevocationStatus; }
|
|
|
|
}
|
2014-08-13 10:39:27 +01:00
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
X509Certificate MNS.IMonoSslStream.InternalLocalCertificate {
|
|
|
|
get { return Impl.InternalLocalCertificate; }
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public virtual X509Certificate LocalCertificate {
|
2016-02-22 11:00:01 -05:00
|
|
|
get { return Impl.LocalCertificate; }
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public virtual X509Certificate RemoteCertificate {
|
2016-02-22 11:00:01 -05:00
|
|
|
get { return Impl.RemoteCertificate; }
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public virtual CipherAlgorithmType CipherAlgorithm {
|
|
|
|
get { return (CipherAlgorithmType)Impl.CipherAlgorithm; }
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public virtual int CipherStrength {
|
|
|
|
get { return Impl.CipherStrength; }
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public virtual HashAlgorithmType HashAlgorithm {
|
|
|
|
get { return (HashAlgorithmType)Impl.HashAlgorithm; }
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public virtual int HashStrength {
|
|
|
|
get { return Impl.HashStrength; }
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public virtual ExchangeAlgorithmType KeyExchangeAlgorithm {
|
|
|
|
get { return (ExchangeAlgorithmType)Impl.KeyExchangeAlgorithm; }
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public virtual int KeyExchangeStrength {
|
|
|
|
get { return Impl.KeyExchangeStrength; }
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public override bool CanSeek {
|
|
|
|
get { return false; }
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public override bool CanRead {
|
|
|
|
get { return Impl.CanRead; }
|
|
|
|
}
|
2014-08-13 10:39:27 +01:00
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public override bool CanTimeout {
|
|
|
|
get { return Impl.CanTimeout; }
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public override bool CanWrite {
|
|
|
|
get { return Impl.CanWrite; }
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public override int ReadTimeout {
|
|
|
|
get { return Impl.ReadTimeout; }
|
|
|
|
set { Impl.ReadTimeout = value; }
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public override int WriteTimeout {
|
|
|
|
get { return Impl.WriteTimeout; }
|
|
|
|
set { Impl.WriteTimeout = value; }
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public override long Length {
|
|
|
|
get { return Impl.Length; }
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public override long Position {
|
|
|
|
get { return Impl.Position; }
|
|
|
|
set {
|
|
|
|
throw new NotSupportedException (SR.GetString (SR.net_noseek));
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public override void SetLength (long value)
|
2014-08-13 10:39:27 +01:00
|
|
|
{
|
2016-02-22 11:00:01 -05:00
|
|
|
Impl.SetLength (value);
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public override long Seek (long offset, SeekOrigin origin)
|
2014-08-13 10:39:27 +01:00
|
|
|
{
|
2016-02-22 11:00:01 -05:00
|
|
|
throw new NotSupportedException (SR.GetString (SR.net_noseek));
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public override void Flush ()
|
2014-08-13 10:39:27 +01:00
|
|
|
{
|
2016-02-22 11:00:01 -05:00
|
|
|
Impl.Flush ();
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
void CheckDisposed ()
|
2014-08-13 10:39:27 +01:00
|
|
|
{
|
2016-02-22 11:00:01 -05:00
|
|
|
if (impl == null)
|
|
|
|
throw new ObjectDisposedException ("SslStream");
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
protected override void Dispose (bool disposing)
|
2014-08-13 10:39:27 +01:00
|
|
|
{
|
2016-02-22 11:00:01 -05:00
|
|
|
try {
|
|
|
|
if (impl != null && disposing) {
|
|
|
|
impl.Dispose ();
|
|
|
|
impl = null;
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
base.Dispose (disposing);
|
|
|
|
}
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public override int Read (byte[] buffer, int offset, int count)
|
|
|
|
{
|
2016-02-22 11:00:01 -05:00
|
|
|
return Impl.Read (buffer, offset, count);
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public void Write (byte[] buffer)
|
2014-08-13 10:39:27 +01:00
|
|
|
{
|
2016-02-22 11:00:01 -05:00
|
|
|
Impl.Write (buffer);
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public override void Write (byte[] buffer, int offset, int count)
|
|
|
|
{
|
2016-02-22 11:00:01 -05:00
|
|
|
Impl.Write (buffer, offset, count);
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
// [HostProtection (ExternalThreading=true)]
|
|
|
|
public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
|
2014-08-13 10:39:27 +01:00
|
|
|
{
|
2016-02-22 11:00:01 -05:00
|
|
|
return Impl.BeginRead (buffer, offset, count, asyncCallback, asyncState);
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public override int EndRead (IAsyncResult asyncResult)
|
2014-08-13 10:39:27 +01:00
|
|
|
{
|
2016-02-22 11:00:01 -05:00
|
|
|
return Impl.EndRead (asyncResult);
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
// [HostProtection (ExternalThreading=true)]
|
|
|
|
public override IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
|
2014-08-13 10:39:27 +01:00
|
|
|
{
|
2016-02-22 11:00:01 -05:00
|
|
|
return Impl.BeginWrite (buffer, offset, count, asyncCallback, asyncState);
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
public override void EndWrite (IAsyncResult asyncResult)
|
2014-08-13 10:39:27 +01:00
|
|
|
{
|
2016-02-22 11:00:01 -05:00
|
|
|
Impl.EndWrite (asyncResult);
|
|
|
|
}
|
2014-08-13 10:39:27 +01:00
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
AuthenticatedStream MNS.IMonoSslStream.AuthenticatedStream {
|
|
|
|
get { return this; }
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
MonoTlsProvider MNS.IMonoSslStream.Provider {
|
|
|
|
get { return provider; }
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:00:01 -05:00
|
|
|
MonoTlsConnectionInfo MNS.IMonoSslStream.GetConnectionInfo ()
|
2014-08-13 10:39:27 +01:00
|
|
|
{
|
2016-02-22 11:00:01 -05:00
|
|
|
return Impl.GetConnectionInfo ();
|
2014-08-13 10:39:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-02-22 11:00:01 -05:00
|
|
|
#else // !SECURITY_DEP
|
|
|
|
namespace System.Net.Security
|
|
|
|
{
|
|
|
|
public class SslStream
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|