Imported Upstream version 5.4.0.167

Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-08-21 15:34:15 +00:00
parent e49d6f06c0
commit 536cd135cc
12856 changed files with 563812 additions and 223249 deletions

View File

@ -17,7 +17,10 @@ endif
RESX_RESOURCE_STRING = \
../../../external/corefx/src/System.Collections.Concurrent/src/Resources/Strings.resx \
../../../external/corefx/src/System.Collections/src/Resources/Strings.resx \
../../../external/corefx/src/System.Buffers/src/Resources/Strings.resx
../../../external/corefx/src/System.Buffers/src/Resources/Strings.resx \
../../../external/corefx/src/System.Private.Uri/src/Resources/Strings.resx \
../../../external/corefx/src/System.IO.Ports/src/Resources/Strings.resx \
../../../external/corefx/src/System.Net.HttpListener/src/Resources/Strings.resx
TEST_RESOURCES = \
Test/System/test-uri-props.txt \
@ -117,6 +120,7 @@ endif
EXTRA_DISTFILES = \
common.sources \
common_networking.sources \
Test/test-config-file \
Test/System.Security.Cryptography.X509Certificates/pkits/Makefile \
Test/System.Security.Cryptography.X509Certificates/pkits/README \

View File

@ -143,6 +143,12 @@ namespace Mono.AppleTls
trust.SetAnchorCertificatesOnly (false);
}
if (validator.Settings.CertificateValidationTime != null) {
var status = trust.SetVerifyDate (validator.Settings.CertificateValidationTime.Value);
if (status != SecStatusCode.Success)
throw new InvalidOperationException (status.ToString ());
}
var result = trust.Evaluate ();
if (result == SecTrustResult.Unspecified)
return true;

View File

@ -848,12 +848,12 @@ namespace Mono.AppleTls
[DllImport (SecurityLibrary)]
extern static /* OSStatus */ SslStatus SSLClose (/* SSLContextRef */ IntPtr context);
public override void Close ()
public override void Shutdown ()
{
if (Interlocked.Exchange (ref pendingIO, 1) == 1)
throw new InvalidOperationException ();
Debug ("Close");
Debug ("Shutdown");
lastException = null;
@ -862,7 +862,7 @@ namespace Mono.AppleTls
return;
var status = SSLClose (Handle);
Debug ("Close done: {0}", status);
Debug ("Shutdown done: {0}", status);
CheckStatusAndThrow (status);
} finally {
closed = true;

View File

@ -16,6 +16,7 @@ using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using System.Net.Security;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
@ -30,21 +31,26 @@ namespace Mono.AppleTls
{
class AppleTlsProvider : MonoTlsProvider
{
static readonly Guid id = new Guid ("981af8af-a3a3-419a-9f01-a518e3a17c1c");
public override string Name {
get { return "apple-tls"; }
}
public override Guid ID {
get { return id; }
get { return MNS.MonoTlsProviderFactory.AppleTlsId; }
}
public override IMonoSslStream CreateSslStream (
Stream innerStream, bool leaveInnerStreamOpen,
MonoTlsSettings settings = null)
{
return new AppleTlsStream (innerStream, leaveInnerStreamOpen, settings, this);
return SslStream.CreateMonoSslStream (innerStream, leaveInnerStreamOpen, this, settings);
}
internal override IMonoSslStream CreateSslStreamInternal (
SslStream sslStream, Stream innerStream, bool leaveInnerStreamOpen,
MonoTlsSettings settings)
{
return new AppleTlsStream (innerStream, leaveInnerStreamOpen, sslStream, settings, this);
}
public override bool SupportsSslStream {

View File

@ -16,6 +16,7 @@ using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using System.Net.Security;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
@ -30,18 +31,19 @@ namespace Mono.AppleTls
{
class AppleTlsStream : MNS.MobileAuthenticatedStream
{
public AppleTlsStream (Stream innerStream, bool leaveInnerStreamOpen, MonoTlsSettings settings, MonoTlsProvider provider)
: base (innerStream, leaveInnerStreamOpen, settings, provider)
public AppleTlsStream (Stream innerStream, bool leaveInnerStreamOpen, SslStream owner,
MonoTlsSettings settings, MonoTlsProvider provider)
: base (innerStream, leaveInnerStreamOpen, owner, settings, provider)
{
}
protected override MNS.MobileTlsContext CreateContext (
MNS.MobileAuthenticatedStream parent, bool serverMode, string targetHost,
SslProtocols enabledProtocols, X509Certificate serverCertificate,
X509CertificateCollection clientCertificates, bool askForClientCert)
bool serverMode, string targetHost, SslProtocols enabledProtocols,
X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
bool askForClientCert)
{
return new AppleTlsContext (
parent, serverMode, targetHost,
this, serverMode, targetHost,
enabledProtocols, serverCertificate,
clientCertificates, askForClientCert);
}

View File

@ -159,6 +159,15 @@ namespace Mono.AppleTls {
return SecTrustSetAnchorCertificatesOnly (handle, anchorCertificatesOnly);
}
[DllImport (AppleTlsContext.SecurityLibrary)]
extern static SecStatusCode /* OSStatus */ SecTrustSetVerifyDate (IntPtr /* SecTrustRef */ trust, IntPtr /* CFDateRef */ date);
public SecStatusCode SetVerifyDate (DateTime date)
{
using (var nativeDate = CFDate.Create (date))
return SecTrustSetVerifyDate (handle, nativeDate.Handle);
}
~SecTrust ()
{
Dispose (false);

View File

@ -234,7 +234,7 @@ namespace Mono.Btls
if (!IsServer)
ctx.SetSelectCallback (SelectCallback);
ctx.SetVerifyParam (MonoBtlsProvider.GetVerifyParam (ServerName, IsServer));
ctx.SetVerifyParam (MonoBtlsProvider.GetVerifyParam (Settings, ServerName, IsServer));
TlsProtocolCode minProtocol, maxProtocol;
GetProtocolVersions (out minProtocol, out maxProtocol);
@ -316,6 +316,9 @@ namespace Mono.Btls
if (status == MonoBtlsSslError.WantRead) {
wantMore = true;
return 0;
} else if (status == MonoBtlsSslError.ZeroReturn) {
wantMore = false;
return size;
} else if (status != MonoBtlsSslError.None) {
throw GetException (status);
}
@ -358,26 +361,11 @@ namespace Mono.Btls
}
}
public override void Close ()
public override void Shutdown ()
{
Debug ("Close!");
if (ssl != null) {
ssl.Dispose ();
ssl = null;
}
if (ctx != null) {
ctx.Dispose ();
ctx = null;
}
if (bio != null) {
bio.Dispose ();
bio = null;
}
if (errbio != null) {
errbio.Dispose ();
errbio = null;
}
Debug ("Shutdown!");
// ssl.SetQuietShutdown ();
ssl.Shutdown ();
}
void Dispose<T> (ref T disposable)
@ -397,12 +385,12 @@ namespace Mono.Btls
{
try {
if (disposing) {
Dispose (ref ssl);
Dispose (ref ctx);
Dispose (ref remoteCertificate);
Dispose (ref nativeServerCertificate);
Dispose (ref nativeClientCertificate);
Dispose (ref clientCertificate);
Dispose (ref ctx);
Dispose (ref ssl);
Dispose (ref bio);
Dispose (ref errbio);
}

View File

@ -102,6 +102,20 @@ namespace Mono.Btls
CheckError (ret == 1, callerName);
}
protected internal void CheckLastError ([CallerMemberName] string callerName = null)
{
var error = Interlocked.Exchange (ref lastError, null);
if (error == null)
return;
string message;
if (callerName != null)
message = string.Format ("Caught unhandled exception in {0}.{1}.", GetType ().Name, callerName);
else
message = string.Format ("Caught unhandled exception.");
throw new MonoBtlsException (message, error);
}
[DllImport (BTLS_DYLIB)]
extern static void mono_btls_free (IntPtr data);

View File

@ -32,6 +32,7 @@ using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Security.Authentication;
@ -49,10 +50,8 @@ namespace Mono.Btls
{
class MonoBtlsProvider : MonoTlsProvider
{
static readonly Guid id = new Guid ("432d18c9-9348-4b90-bfbf-9f2a10e1f15b");
public override Guid ID {
get { return id; }
get { return MNS.MonoTlsProviderFactory.BtlsId; }
}
public override string Name {
get { return "btls"; }
@ -83,9 +82,16 @@ namespace Mono.Btls
public override IMonoSslStream CreateSslStream (
Stream innerStream, bool leaveInnerStreamOpen,
MonoTlsSettings settings = null)
{
return SslStream.CreateMonoSslStream (innerStream, leaveInnerStreamOpen, this, settings);
}
internal override IMonoSslStream CreateSslStreamInternal (
SslStream sslStream, Stream innerStream, bool leaveInnerStreamOpen,
MonoTlsSettings settings)
{
return new MonoBtlsStream (
innerStream, leaveInnerStreamOpen, settings, this);
innerStream, leaveInnerStreamOpen, sslStream, settings, this);
}
internal override bool HasNativeCertificates {
@ -111,7 +117,7 @@ namespace Mono.Btls
return new X509CertificateImplBtls (data, MonoBtlsX509Format.DER, false);
}
internal static MonoBtlsX509VerifyParam GetVerifyParam (string targetHost, bool serverMode)
internal static MonoBtlsX509VerifyParam GetVerifyParam (MonoTlsSettings settings, string targetHost, bool serverMode)
{
MonoBtlsX509VerifyParam param;
if (serverMode)
@ -119,12 +125,15 @@ namespace Mono.Btls
else
param = MonoBtlsX509VerifyParam.GetSslServer ();
if (targetHost == null)
if (targetHost == null && settings?.CertificateValidationTime == null)
return param;
try {
var copy = param.Copy ();
copy.SetHost (targetHost);
if (targetHost != null)
copy.SetHost (targetHost);
if (settings?.CertificateValidationTime != null)
copy.SetTime (settings.CertificateValidationTime.Value);
return copy;
} finally {
param.Dispose ();
@ -148,7 +157,7 @@ namespace Mono.Btls
using (var store = new MonoBtlsX509Store ())
using (var nativeChain = MonoBtlsProvider.GetNativeChain (certificates))
using (var param = GetVerifyParam (targetHost, serverMode))
using (var param = GetVerifyParam (validator.Settings, targetHost, serverMode))
using (var storeCtx = new MonoBtlsX509StoreCtx ()) {
SetupCertificateStore (store, validator.Settings, serverMode);
@ -176,7 +185,12 @@ namespace Mono.Btls
{
using (var store = new MonoBtlsX509Store ())
using (var storeCtx = new MonoBtlsX509StoreCtx ()) {
SetupCertificateStore (store);
/*
* We're called from X509Certificate2.Verify() via X509CertificateImplBtls.Verify().
*
* Use the default settings and assume client-mode.
*/
SetupCertificateStore (store, MonoTlsSettings.DefaultSettings, false);
storeCtx.Initialize (store, chain);
@ -203,46 +217,62 @@ namespace Mono.Btls
internal static void SetupCertificateStore (MonoBtlsX509Store store, MonoTlsSettings settings, bool server)
{
if (settings?.CertificateSearchPaths == null)
AddTrustedRoots (store, settings, server);
/*
* In server-mode, we only add certificates which are explicitly trusted via
* MonoTlsSettings.TrustAnchors.
*
* MonoTlsSettings.CertificateSearchPaths is ignored on Android.
*
*/
#if MONODROID
SetupCertificateStore (store);
AddTrustedRoots (store, settings, server);
if (!server)
SetupDefaultCertificateStore (store);
return;
#else
if (settings?.CertificateSearchPaths == null) {
SetupCertificateStore (store);
if (server || settings?.CertificateSearchPaths == null) {
AddTrustedRoots (store, settings, server);
if (!server)
SetupDefaultCertificateStore (store);
return;
}
foreach (var path in settings.CertificateSearchPaths) {
if (string.Equals (path, "@default", StringComparison.Ordinal)) {
switch (path) {
case "@default":
AddTrustedRoots (store, settings, server);
AddUserStore (store);
AddMachineStore (store);
} else if (string.Equals (path, "@user", StringComparison.Ordinal))
AddUserStore (store);
else if (string.Equals (path, "@machine", StringComparison.Ordinal))
AddMachineStore (store);
else if (string.Equals (path, "@trusted", StringComparison.Ordinal))
break;
case "@trusted":
AddTrustedRoots (store, settings, server);
else if (path.StartsWith ("@pem:", StringComparison.Ordinal)) {
var realPath = path.Substring (5);
if (Directory.Exists (realPath))
store.AddDirectoryLookup (realPath, MonoBtlsX509FileType.PEM);
} else if (path.StartsWith ("@der:", StringComparison.Ordinal)) {
var realPath = path.Substring (5);
if (Directory.Exists (realPath))
store.AddDirectoryLookup (realPath, MonoBtlsX509FileType.ASN1);
} else {
if (Directory.Exists (path))
store.AddDirectoryLookup (path, MonoBtlsX509FileType.PEM);
break;
case "@user":
AddUserStore (store);
break;
case "@machine":
AddMachineStore (store);
break;
default:
if (path.StartsWith ("@pem:")) {
var realPath = path.Substring (5);
if (Directory.Exists (realPath))
store.AddDirectoryLookup (realPath, MonoBtlsX509FileType.PEM);
break;
} else if (path.StartsWith ("@der:")) {
var realPath = path.Substring (5);
if (Directory.Exists (realPath))
store.AddDirectoryLookup (realPath, MonoBtlsX509FileType.ASN1);
break;
}
throw new NotSupportedException (string.Format ("Invalid item `{0}' in MonoTlsSettings.CertificateSearchPaths.", path));
}
}
#endif
}
internal static void SetupCertificateStore (MonoBtlsX509Store store)
static void SetupDefaultCertificateStore (MonoBtlsX509Store store)
{
#if MONODROID
store.SetDefaultPaths ();

View File

@ -47,6 +47,7 @@ namespace Mono.Btls
protected override bool ReleaseHandle ()
{
mono_btls_ssl_destroy (handle);
handle = IntPtr.Zero;
return true;
}
}
@ -78,6 +79,12 @@ namespace Mono.Btls
[DllImport (BTLS_DYLIB)]
extern static void mono_btls_ssl_close (IntPtr handle);
[DllImport (BTLS_DYLIB)]
extern static int mono_btls_ssl_shutdown (IntPtr handle);
[DllImport (BTLS_DYLIB)]
extern static void mono_btls_ssl_set_quiet_shutdown (IntPtr handle, int mode);
[DllImport (BTLS_DYLIB)]
extern static void mono_btls_ssl_set_bio (IntPtr handle, IntPtr bio);
@ -131,6 +138,7 @@ namespace Mono.Btls
return new BoringSslHandle (handle);
}
MonoBtlsBio bio;
PrintErrorsCallbackFunc printErrorsFunc;
IntPtr printErrorsFuncPtr;
@ -148,6 +156,7 @@ namespace Mono.Btls
public void SetBio (MonoBtlsBio bio)
{
CheckThrow ();
this.bio = bio;
mono_btls_ssl_set_bio (
Handle.DangerousGetHandle (),
bio.Handle.DangerousGetHandle ());
@ -164,18 +173,17 @@ namespace Mono.Btls
errors = null;
}
if (errors != null) {
Console.Error.WriteLine ("ERROR: {0} failed: {1}", callerName, errors);
if (errors != null)
throw new MonoBtlsException ("{0} failed: {1}.", callerName, errors);
} else {
Console.Error.WriteLine ("ERROR: {0} failed.", callerName);
else
throw new MonoBtlsException ("{0} failed.", callerName);
}
}
MonoBtlsSslError GetError (int ret_code)
{
CheckThrow ();
bio.CheckLastError ();
var error = mono_btls_ssl_get_error (
Handle.DangerousGetHandle (), ret_code);
return (MonoBtlsSslError)error;
@ -287,15 +295,20 @@ namespace Mono.Btls
var ret = mono_btls_ssl_read (
Handle.DangerousGetHandle (), data, dataSize);
if (ret >= 0) {
if (ret > 0) {
dataSize = ret;
return MonoBtlsSslError.None;
}
var error = mono_btls_ssl_get_error (
Handle.DangerousGetHandle (), ret);
var error = GetError (ret);
if (ret == 0 && error == MonoBtlsSslError.Syscall) {
// End-of-stream
dataSize = 0;
return MonoBtlsSslError.None;
}
dataSize = 0;
return (MonoBtlsSslError)error;
return error;
}
public MonoBtlsSslError Write (IntPtr data, ref int dataSize)
@ -416,9 +429,24 @@ namespace Mono.Btls
return Marshal.PtrToStringAnsi (namePtr);
}
public void Shutdown ()
{
CheckThrow ();
var ret = mono_btls_ssl_shutdown (Handle.DangerousGetHandle ());
if (ret < 0)
throw ThrowError ();
}
public void SetQuietShutdown ()
{
CheckThrow ();
mono_btls_ssl_set_quiet_shutdown (Handle.DangerousGetHandle (), 1);
}
protected override void Close ()
{
mono_btls_ssl_close (Handle.DangerousGetHandle ());
if (!Handle.IsInvalid)
mono_btls_ssl_close (Handle.DangerousGetHandle ());
}
}
}

View File

@ -30,6 +30,7 @@ extern alias MonoSecurity;
using System;
using System.IO;
using System.Net.Security;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
@ -45,18 +46,19 @@ namespace Mono.Btls
{
class MonoBtlsStream : MNS.MobileAuthenticatedStream
{
public MonoBtlsStream (Stream innerStream, bool leaveInnerStreamOpen, MonoTlsSettings settings, MonoTlsProvider provider)
: base (innerStream, leaveInnerStreamOpen, settings, provider)
public MonoBtlsStream (Stream innerStream, bool leaveInnerStreamOpen, SslStream owner,
MonoTlsSettings settings, MonoTlsProvider provider)
: base (innerStream, leaveInnerStreamOpen, owner, settings, provider)
{
}
protected override MNS.MobileTlsContext CreateContext (
MNS.MobileAuthenticatedStream parent, bool serverMode, string targetHost,
SslProtocols enabledProtocols, X509Certificate serverCertificate,
X509CertificateCollection clientCertificates, bool askForClientCert)
bool serverMode, string targetHost, SslProtocols enabledProtocols,
X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
bool askForClientCert)
{
return new MonoBtlsContext (
parent, serverMode, targetHost,
this, serverMode, targetHost,
enabledProtocols, serverCertificate,
clientCertificates, askForClientCert);
}

View File

@ -24,6 +24,9 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if SECURITY_DEP && MONO_FEATURE_BTLS
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
using System;
using System.IO;
using System.Collections.Generic;
@ -31,6 +34,12 @@ using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
#if MONO_SECURITY_ALIAS
using MonoSecurity::Mono.Security.Interface;
#else
using Mono.Security.Interface;
#endif
namespace Mono.Btls
{
class MonoBtlsX509Store : MonoBtlsObject
@ -159,7 +168,7 @@ namespace Mono.Btls
internal void AddTrustedRoots ()
{
MonoBtlsProvider.SetupCertificateStore (this);
MonoBtlsProvider.SetupCertificateStore (this, MonoTlsSettings.DefaultSettings, false);
}
public MonoBtlsX509Lookup AddLookup (MonoBtlsX509LookupType type)

View File

@ -11,14 +11,14 @@ using System;
using System.IO;
using System.Net;
using System.Net.Security;
using System.Security.Authentication;
using SD = System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using System.Runtime.ExceptionServices;
namespace Mono.Net.Security
{
delegate AsyncOperationStatus AsyncOperation (AsyncProtocolRequest asyncRequest, AsyncOperationStatus status);
class BufferOffsetSize
{
public byte[] Buffer;
@ -37,6 +37,13 @@ namespace Mono.Net.Security
public BufferOffsetSize (byte[] buffer, int offset, int size)
{
if (buffer == null)
throw new ArgumentNullException (nameof (buffer));
if (offset < 0)
throw new ArgumentOutOfRangeException (nameof (offset));
if (size < 0 || offset + size > buffer.Length)
throw new ArgumentOutOfRangeException (nameof (size));
Buffer = buffer;
Offset = offset;
Size = size;
@ -54,7 +61,7 @@ namespace Mono.Net.Security
public readonly int InitialSize;
public BufferOffsetSize2 (int size)
: base (new byte [size], 0, 0)
: base (new byte[size], 0, 0)
{
InitialSize = size;
}
@ -63,7 +70,7 @@ namespace Mono.Net.Security
{
Offset = Size = 0;
TotalBytes = 0;
Buffer = new byte [InitialSize];
Buffer = new byte[InitialSize];
Complete = false;
}
@ -74,11 +81,11 @@ namespace Mono.Net.Security
int missing = size - Remaining;
if (Offset == 0 && Size == 0) {
Buffer = new byte [size];
Buffer = new byte[size];
return;
}
var buffer = new byte [Buffer.Length + missing];
var buffer = new byte[Buffer.Length + missing];
Buffer.CopyTo (buffer, 0);
Buffer = buffer;
}
@ -91,201 +98,296 @@ namespace Mono.Net.Security
}
}
enum AsyncOperationStatus {
NotStarted,
enum AsyncOperationStatus
{
Initialize,
Continue,
Running,
Complete,
WantRead,
WantWrite,
ReadDone,
FinishWrite
Complete
}
class AsyncProtocolRequest
class AsyncProtocolResult
{
public readonly MobileAuthenticatedStream Parent;
public readonly BufferOffsetSize UserBuffer;
int RequestedSize;
public int CurrentSize;
public int UserResult;
AsyncOperation Operation;
int Status;
public readonly int ID = ++next_id;
static int next_id;
public readonly LazyAsyncResult UserAsyncResult;
public AsyncProtocolRequest (MobileAuthenticatedStream parent, LazyAsyncResult lazyResult, BufferOffsetSize userBuffer = null)
{
Parent = parent;
UserAsyncResult = lazyResult;
UserBuffer = userBuffer;
public int UserResult {
get;
}
public ExceptionDispatchInfo Error {
get;
}
public bool CompleteWithError (Exception ex)
public AsyncProtocolResult (int result)
{
Status = (int)AsyncOperationStatus.Complete;
if (UserAsyncResult == null)
return true;
if (!UserAsyncResult.InternalPeekCompleted)
UserAsyncResult.InvokeCallback (ex);
return false;
UserResult = result;
}
public AsyncProtocolResult (ExceptionDispatchInfo error)
{
Error = error;
}
}
abstract class AsyncProtocolRequest
{
public MobileAuthenticatedStream Parent {
get;
}
public bool RunSynchronously {
get;
}
public int ID => ++next_id;
public string Name => GetType ().Name;
public int UserResult {
get;
protected set;
}
int Started;
int RequestedSize;
int WriteRequested;
readonly object locker = new object ();
static int next_id;
public AsyncProtocolRequest (MobileAuthenticatedStream parent, bool sync)
{
Parent = parent;
RunSynchronously = sync;
}
[SD.Conditional ("MARTIN_DEBUG")]
protected void Debug (string message, params object[] args)
{
Parent.Debug ("AsyncProtocolRequest({0}:{1}): {2}", Parent.ID, ID, string.Format (message, args));
Parent.Debug ("{0}({1}:{2}): {3}", Name, Parent.ID, ID, string.Format (message, args));
}
internal void RequestRead (int size)
{
var oldStatus = (AsyncOperationStatus)Interlocked.CompareExchange (ref Status, (int)AsyncOperationStatus.WantRead, (int)AsyncOperationStatus.Running);
Debug ("RequestRead: {0} {1}", oldStatus, size);
if (oldStatus == AsyncOperationStatus.Running)
RequestedSize = size;
else if (oldStatus == AsyncOperationStatus.WantRead)
lock (locker) {
RequestedSize += size;
else if (oldStatus != AsyncOperationStatus.WantWrite)
throw new InvalidOperationException ();
}
internal void ResetRead ()
{
var oldStatus = (AsyncOperationStatus)Interlocked.CompareExchange (ref Status, (int)AsyncOperationStatus.Complete, (int)AsyncOperationStatus.WantRead);
Debug ("ResetRead: {0} {1}", oldStatus, Status);
}
internal void ResetWrite ()
{
var oldStatus = (AsyncOperationStatus)Interlocked.CompareExchange (ref Status, (int)AsyncOperationStatus.Complete, (int)AsyncOperationStatus.WantWrite);
Debug ("ResetWrite: {0} {1}", oldStatus, Status);
Debug ("RequestRead: {0}", size);
}
}
internal void RequestWrite ()
{
var oldStatus = (AsyncOperationStatus)Interlocked.CompareExchange (ref Status, (int)AsyncOperationStatus.WantWrite, (int)AsyncOperationStatus.Running);
Debug ("RequestWrite: {0} {1}", oldStatus, Status);
if (oldStatus == AsyncOperationStatus.Running)
return;
else if (oldStatus != AsyncOperationStatus.WantRead && oldStatus != AsyncOperationStatus.WantWrite)
throw new InvalidOperationException ();
WriteRequested = 1;
}
internal void StartOperation (AsyncOperation operation)
internal async Task<AsyncProtocolResult> StartOperation (CancellationToken cancellationToken)
{
Debug ("Start Operation: {0} {1}", Status, operation);
if (Interlocked.CompareExchange (ref Status, (int)AsyncOperationStatus.Initialize, (int)AsyncOperationStatus.NotStarted) != (int)AsyncOperationStatus.NotStarted)
Debug ("Start Operation: {0}", this);
if (Interlocked.CompareExchange (ref Started, 1, 0) != 0)
throw new InvalidOperationException ();
Operation = operation;
if (UserAsyncResult == null) {
StartOperation ();
return;
}
ThreadPool.QueueUserWorkItem (_ => StartOperation ());
}
void StartOperation ()
{
try {
ProcessOperation ();
if (UserAsyncResult != null && !UserAsyncResult.InternalPeekCompleted)
UserAsyncResult.InvokeCallback (UserResult);
await ProcessOperation (cancellationToken).ConfigureAwait (false);
return new AsyncProtocolResult (UserResult);
} catch (Exception ex) {
if (UserAsyncResult == null)
throw;
if (!UserAsyncResult.InternalPeekCompleted)
UserAsyncResult.InvokeCallback (ex);
var info = Parent.SetException (MobileAuthenticatedStream.GetSSPIException (ex));
return new AsyncProtocolResult (info);
}
}
void ProcessOperation ()
async Task ProcessOperation (CancellationToken cancellationToken)
{
AsyncOperationStatus status;
do {
status = (AsyncOperationStatus)Interlocked.Exchange (ref Status, (int)AsyncOperationStatus.Running);
var status = AsyncOperationStatus.Initialize;
while (status != AsyncOperationStatus.Complete) {
cancellationToken.ThrowIfCancellationRequested ();
Debug ("ProcessOperation: {0}", status);
status = ProcessOperation (status);
Debug ("ProcessOperation done: {0}", status);
AsyncOperationStatus oldStatus;
if (status == AsyncOperationStatus.Complete) {
oldStatus = (AsyncOperationStatus)Interlocked.CompareExchange (ref Status, (int)AsyncOperationStatus.FinishWrite, (int)AsyncOperationStatus.WantWrite);
if (oldStatus == AsyncOperationStatus.WantWrite) {
// We are done, but still need to flush the write queue.
status = AsyncOperationStatus.FinishWrite;
continue;
var ret = await InnerRead (cancellationToken).ConfigureAwait (false);
if (ret != null) {
if (ret == 0) {
// End-of-stream
Debug ("END OF STREAM!");
status = AsyncOperationStatus.ReadDone;
} else if (ret < 0) {
// remote prematurely closed connection.
throw new IOException ("Remote prematurely closed connection.");
}
}
oldStatus = (AsyncOperationStatus)Interlocked.CompareExchange (ref Status, (int)status, (int)AsyncOperationStatus.Running);
Debug ("ProcessOperation done: {0} -> {1}", oldStatus, status);
Debug ("ProcessOperation run: {0}", status);
if (oldStatus != AsyncOperationStatus.Running) {
if (status == oldStatus || status == AsyncOperationStatus.Continue || status == AsyncOperationStatus.Complete)
status = oldStatus;
else
throw new InvalidOperationException ();
AsyncOperationStatus newStatus;
switch (status) {
case AsyncOperationStatus.Initialize:
case AsyncOperationStatus.Continue:
case AsyncOperationStatus.ReadDone:
newStatus = Run (status);
break;
default:
throw new InvalidOperationException ();
}
} while (status != AsyncOperationStatus.Complete);
if (Interlocked.Exchange (ref WriteRequested, 0) != 0) {
// Flush the write queue.
await Parent.InnerWrite (RunSynchronously, cancellationToken);
}
Debug ("ProcessOperation done: {0} -> {1}", status, newStatus);
status = newStatus;
}
}
AsyncOperationStatus ProcessOperation (AsyncOperationStatus status)
async Task<int?> InnerRead (CancellationToken cancellationToken)
{
if (status == AsyncOperationStatus.WantRead) {
if (RequestedSize < 0)
int? totalRead = null;
var requestedSize = Interlocked.Exchange (ref RequestedSize, 0);
while (requestedSize > 0) {
Debug ("ProcessOperation - read inner: {0}", requestedSize);
var ret = await Parent.InnerRead (RunSynchronously, requestedSize, cancellationToken).ConfigureAwait (false);
Debug ("ProcessOperation - read inner done: {0} - {1}", requestedSize, ret);
if (ret <= 0)
return ret;
if (ret > requestedSize)
throw new InvalidOperationException ();
else if (RequestedSize == 0)
return AsyncOperationStatus.Continue;
Debug ("ProcessOperation - read inner: {0}", RequestedSize);
var ret = Parent.InnerRead (RequestedSize);
Debug ("ProcessOperation - read inner done: {0} - {1}", RequestedSize, ret);
totalRead += ret;
requestedSize -= ret;
var newRequestedSize = Interlocked.Exchange (ref RequestedSize, 0);
requestedSize += newRequestedSize;
}
if (ret < 0)
return AsyncOperationStatus.ReadDone;
return totalRead;
}
RequestedSize -= ret;
/*
* This will operate on the internal buffers and never block.
*/
protected abstract AsyncOperationStatus Run (AsyncOperationStatus status);
if (ret == 0 || RequestedSize == 0)
return AsyncOperationStatus.Continue;
else
return AsyncOperationStatus.WantRead;
} else if (status == AsyncOperationStatus.WantWrite) {
Debug ("ProcessOperation - want write");
Parent.InnerWrite ();
Debug ("ProcessOperation - want write done");
return AsyncOperationStatus.Continue;
} else if (status == AsyncOperationStatus.Initialize || status == AsyncOperationStatus.Continue) {
Debug ("ProcessOperation - continue");
status = Operation (this, status);
Debug ("ProcessOperation - continue done: {0}", status);
return status;
} else if (status == AsyncOperationStatus.ReadDone) {
Debug ("ProcessOperation - read done");
status = Operation (this, status);
Debug ("ProcessOperation - read done: {0}", status);
return status;
} else if (status == AsyncOperationStatus.FinishWrite) {
Debug ("ProcessOperation - finish write");
Parent.InnerWrite ();
Debug ("ProcessOperation - finish write done");
public override string ToString ()
{
return string.Format ("[{0}]", Name);
}
}
class AsyncHandshakeRequest : AsyncProtocolRequest
{
public AsyncHandshakeRequest (MobileAuthenticatedStream parent, bool sync)
: base (parent, sync)
{
}
protected override AsyncOperationStatus Run (AsyncOperationStatus status)
{
return Parent.ProcessHandshake (status);
}
}
abstract class AsyncReadOrWriteRequest : AsyncProtocolRequest
{
protected BufferOffsetSize UserBuffer {
get;
}
protected int CurrentSize {
get; set;
}
public AsyncReadOrWriteRequest (MobileAuthenticatedStream parent, bool sync, byte[] buffer, int offset, int size)
: base (parent, sync)
{
UserBuffer = new BufferOffsetSize (buffer, offset, size);
}
public override string ToString ()
{
return string.Format ("[{0}: {1}]", Name, UserBuffer);
}
}
class AsyncReadRequest : AsyncReadOrWriteRequest
{
public AsyncReadRequest (MobileAuthenticatedStream parent, bool sync, byte[] buffer, int offset, int size)
: base (parent, sync, buffer, offset, size)
{
}
protected override AsyncOperationStatus Run (AsyncOperationStatus status)
{
Debug ("ProcessRead - read user: {0} {1}", this, status);
var (ret, wantMore) = Parent.ProcessRead (UserBuffer);
Debug ("ProcessRead - read user done: {0} - {1} {2}", this, ret, wantMore);
if (ret < 0) {
UserResult = -1;
return AsyncOperationStatus.Complete;
}
throw new InvalidOperationException ();
CurrentSize += ret;
UserBuffer.Offset += ret;
UserBuffer.Size -= ret;
Debug ("Process Read - read user done #1: {0} - {1} {2}", this, CurrentSize, wantMore);
if (wantMore && CurrentSize == 0)
return AsyncOperationStatus.Continue;
UserResult = CurrentSize;
return AsyncOperationStatus.Complete;
}
}
class AsyncWriteRequest : AsyncReadOrWriteRequest
{
public AsyncWriteRequest (MobileAuthenticatedStream parent, bool sync, byte[] buffer, int offset, int size)
: base (parent, sync, buffer, offset, size)
{
}
protected override AsyncOperationStatus Run (AsyncOperationStatus status)
{
Debug ("ProcessWrite - write user: {0} {1}", this, status);
if (UserBuffer.Size == 0) {
UserResult = CurrentSize;
return AsyncOperationStatus.Complete;
}
var (ret, wantMore) = Parent.ProcessWrite (UserBuffer);
Debug ("ProcessWrite - write user done: {0} - {1} {2}", this, ret, wantMore);
if (ret < 0) {
UserResult = -1;
return AsyncOperationStatus.Complete;
}
CurrentSize += ret;
UserBuffer.Offset += ret;
UserBuffer.Size -= ret;
if (wantMore)
return AsyncOperationStatus.Continue;
UserResult = CurrentSize;
return AsyncOperationStatus.Complete;
}
}
class AsyncShutdownRequest : AsyncProtocolRequest
{
public AsyncShutdownRequest (MobileAuthenticatedStream parent)
: base (parent, false)
{
}
protected override AsyncOperationStatus Run (AsyncOperationStatus status)
{
return Parent.ProcessShutdown (status);
}
}
}
#endif

View File

@ -1,233 +0,0 @@
//
// IMonoSslStream.cs
//
// Author:
// Martin Baulig <martin.baulig@xamarin.com>
//
// Copyright (c) 2015 Xamarin, Inc.
//
// 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:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// 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.
#if SECURITY_DEP
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
#if MONO_SECURITY_ALIAS
using MSI = MonoSecurity::Mono.Security.Interface;
#else
using MSI = Mono.Security.Interface;
#endif
#endif
using System;
using System.IO;
using System.Net;
using System.Net.Security;
using System.Threading.Tasks;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using System.Security.Principal;
using System.Security.Cryptography;
namespace Mono.Net.Security
{
interface IMonoSslStream : IDisposable
{
AuthenticatedStream AuthenticatedStream {
get;
}
void AuthenticateAsClient (string targetHost);
void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState);
IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates,
SslProtocols enabledSslProtocols, bool checkCertificateRevocation,
AsyncCallback asyncCallback, object asyncState);
void EndAuthenticateAsClient (IAsyncResult asyncResult);
void AuthenticateAsServer (X509Certificate serverCertificate);
void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired,
SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState);
IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired,
SslProtocols enabledSslProtocols, bool checkCertificateRevocation,
AsyncCallback asyncCallback,
object asyncState);
void EndAuthenticateAsServer (IAsyncResult asyncResult);
TransportContext TransportContext {
get;
}
Task AuthenticateAsClientAsync (string targetHost);
Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
Task AuthenticateAsServerAsync (X509Certificate serverCertificate);
Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
//
//
// Base class properties
//
bool IsAuthenticated {
get;
}
bool IsMutuallyAuthenticated {
get;
}
bool IsEncrypted {
get;
}
bool IsSigned {
get;
}
bool IsServer {
get;
}
//
//
//SSL specific properties
//
//
SslProtocols SslProtocol {
get;
}
bool CheckCertRevocationStatus {
get;
}
X509Certificate InternalLocalCertificate {
get;
}
X509Certificate LocalCertificate {
get;
}
X509Certificate RemoteCertificate {
get;
}
//
// More informational properties
//
CipherAlgorithmType CipherAlgorithm {
get;
}
int CipherStrength {
get;
}
HashAlgorithmType HashAlgorithm {
get;
}
int HashStrength {
get;
}
ExchangeAlgorithmType KeyExchangeAlgorithm {
get;
}
int KeyExchangeStrength {
get;
}
//
//
// Stream contract implementation
//
//
//
bool CanRead {
get;
}
bool CanTimeout {
get;
}
bool CanWrite {
get;
}
int ReadTimeout {
get;
set;
}
int WriteTimeout {
get;
set;
}
long Length {
get;
}
long Position {
get;
}
void SetLength (long value);
void Flush ();
int Read (byte[] buffer, int offset, int count);
void Write (byte[] buffer);
void Write (byte[] buffer, int offset, int count);
IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState);
int EndRead (IAsyncResult asyncResult);
IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState);
void EndWrite (IAsyncResult asyncResult);
#if SECURITY_DEP
MSI.MonoTlsProvider Provider {
get;
}
MSI.MonoTlsConnectionInfo GetConnectionInfo ();
#endif
}
}

View File

@ -1,74 +0,0 @@
//
// IMonoTlsProvider.cs
//
// Author:
// Martin Baulig <martin.baulig@xamarin.com>
//
// Copyright (c) 2015 Xamarin, Inc.
//
// 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:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// 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.
#if SECURITY_DEP
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
#if MONO_SECURITY_ALIAS
using MonoSecurity::Mono.Security.Interface;
#else
using Mono.Security.Interface;
#endif
#endif
using System;
using System.IO;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
namespace Mono.Net.Security
{
/*
* For consumption within System.dll only - do not access from friend assemblies.
*
* Unfortunately, there's some compiler madness involved when using Mono.Security.dll
* APIs from within System.dll because the compiler perceives those types which come
* from the prebuilt version of System.dll being different from those it's currently
* compiling. At runtime, there is only one single System.dll, so these all map to
* the same actual type.
*
* This internal interface helps to keep all this compilation stuff contained within
* the 'Mono.Net.Security.Private' namespace - this namespace should be considered
* strictly private and must not be accessed from files outside the Mono.Net.Security
* directory.
*
*/
interface IMonoTlsProvider
{
#if SECURITY_DEP
MonoTlsProvider Provider {
get;
}
IMonoSslStream CreateSslStream (
Stream innerStream, bool leaveInnerStreamOpen,
MonoTlsSettings settings);
#endif
}
}

View File

@ -81,16 +81,16 @@ namespace Mono.Net.Security.Private
SslStreamBase ssl_stream;
ICertificateValidator certificateValidator;
MonoTlsProvider provider;
#endregion // Fields
#region Constructors
public LegacySslStream (Stream innerStream, bool leaveInnerStreamOpen, MonoTlsProvider provider, MonoTlsSettings settings)
public LegacySslStream (Stream innerStream, bool leaveInnerStreamOpen, SslStream owner, MonoTlsProvider provider, MonoTlsSettings settings)
: base (innerStream, leaveInnerStreamOpen)
{
this.provider = provider;
SslStream = owner;
Provider = provider;
certificateValidator = ChainValidationHelper.GetInternalValidator (provider, settings);
}
#endregion // Constructors
@ -575,6 +575,11 @@ namespace Mono.Net.Security.Private
#region IMonoSslStream
Task IMonoSslStream.ShutdownAsync ()
{
return Task.CompletedTask;
}
AuthenticatedStream IMonoSslStream.AuthenticatedStream {
get { return this; }
}
@ -583,11 +588,15 @@ namespace Mono.Net.Security.Private
get { throw new NotSupportedException (); }
}
MonoTlsProvider IMonoSslStream.Provider {
get { return provider; }
public SslStream SslStream {
get;
}
MonoTlsConnectionInfo IMonoSslStream.GetConnectionInfo ()
public MonoTlsProvider Provider {
get;
}
public MonoTlsConnectionInfo GetConnectionInfo ()
{
return null;
}

View File

@ -48,10 +48,8 @@ namespace Mono.Net.Security
*/
class LegacyTlsProvider : MSI.MonoTlsProvider
{
static readonly Guid id = new Guid ("809e77d5-56cc-4da8-b9f0-45e65ba9cceb");
public override Guid ID {
get { return id; }
get { return MonoTlsProviderFactory.LegacyId; }
}
public override string Name {
@ -78,8 +76,14 @@ namespace Mono.Net.Security
Stream innerStream, bool leaveInnerStreamOpen,
MSI.MonoTlsSettings settings = null)
{
var impl = new Private.LegacySslStream (innerStream, leaveInnerStreamOpen, this, settings);
return new Private.MonoSslStreamImpl (impl);
return SslStream.CreateMonoSslStream (innerStream, leaveInnerStreamOpen, this, settings);
}
internal override MSI.IMonoSslStream CreateSslStreamInternal (
SslStream sslStream, Stream innerStream, bool leaveInnerStreamOpen,
MSI.MonoTlsSettings settings)
{
return new Private.LegacySslStream (innerStream, leaveInnerStreamOpen, sslStream, this, settings);
}
internal override bool ValidateCertificate (

View File

@ -169,7 +169,7 @@ namespace Mono.Net.Security
public abstract int Write (byte[] buffer, int offset, int count, out bool wantMore);
public abstract void Close ();
public abstract void Shutdown ();
protected bool ValidateCertificate (X509Certificate leaf, X509Chain chain)
{

View File

@ -1,318 +0,0 @@
//
// MonoSslStream.cs
//
// Author:
// Martin Baulig <martin.baulig@xamarin.com>
//
// Copyright (c) 2015 Xamarin, Inc.
//
// 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:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// 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.
#if SECURITY_DEP
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
#if MONO_SECURITY_ALIAS
using MSI = MonoSecurity::Mono.Security.Interface;
#else
using MSI = Mono.Security.Interface;
#endif
using System;
using System.IO;
using System.Net;
using System.Net.Security;
using System.Threading.Tasks;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
using System.Security.Principal;
using System.Security.Cryptography;
namespace Mono.Net.Security.Private
{
/*
* Strictly private - do not use outside the Mono.Net.Security directory.
*/
class MonoSslStreamImpl : MSI.IMonoSslStream
{
IMonoSslStream impl;
internal IMonoSslStream Impl {
get {
CheckDisposed ();
return impl;
}
}
public MonoSslStreamImpl (IMonoSslStream impl)
{
this.impl = impl;
}
public void AuthenticateAsClient (string targetHost)
{
Impl.AuthenticateAsClient (targetHost);
}
public void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
Impl.AuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
}
public IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState)
{
return Impl.BeginAuthenticateAsClient (targetHost, asyncCallback, asyncState);
}
public IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
{
return Impl.BeginAuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
}
public void EndAuthenticateAsClient (IAsyncResult asyncResult)
{
Impl.EndAuthenticateAsClient (asyncResult);
}
public void AuthenticateAsServer (X509Certificate serverCertificate)
{
Impl.AuthenticateAsServer (serverCertificate);
}
public void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
Impl.AuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
}
public IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState)
{
return Impl.BeginAuthenticateAsServer (serverCertificate, asyncCallback, asyncState);
}
public IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
{
return Impl.BeginAuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
}
public void EndAuthenticateAsServer (IAsyncResult asyncResult)
{
Impl.EndAuthenticateAsServer (asyncResult);
}
public Task AuthenticateAsClientAsync (string targetHost)
{
return Impl.AuthenticateAsClientAsync (targetHost);
}
public Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
return Impl.AuthenticateAsClientAsync (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
}
public Task AuthenticateAsServerAsync (X509Certificate serverCertificate)
{
return Impl.AuthenticateAsServerAsync (serverCertificate);
}
public Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
{
return Impl.AuthenticateAsServerAsync (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
}
public void Flush ()
{
Impl.Flush ();
}
public int Read (byte[] buffer, int offset, int count)
{
return Impl.Read (buffer, offset, count);
}
public void Write (byte[] buffer)
{
Impl.Write (buffer);
}
public void Write (byte[] buffer, int offset, int count)
{
Impl.Write (buffer, offset, count);
}
public IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
{
return Impl.BeginRead (buffer, offset, count, asyncCallback, asyncState);
}
public int EndRead (IAsyncResult asyncResult)
{
return Impl.EndRead (asyncResult);
}
public IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
{
return Impl.BeginWrite (buffer, offset, count, asyncCallback, asyncState);
}
public void EndWrite (IAsyncResult asyncResult)
{
Impl.EndWrite (asyncResult);
}
public TransportContext TransportContext {
get { return Impl.TransportContext; }
}
public bool IsAuthenticated {
get { return Impl.IsAuthenticated; }
}
public bool IsMutuallyAuthenticated {
get { return Impl.IsMutuallyAuthenticated; }
}
public bool IsEncrypted {
get { return Impl.IsEncrypted; }
}
public bool IsSigned {
get { return Impl.IsSigned; }
}
public bool IsServer {
get { return Impl.IsServer; }
}
public CipherAlgorithmType CipherAlgorithm {
get { return Impl.CipherAlgorithm; }
}
public int CipherStrength {
get { return Impl.CipherStrength; }
}
public HashAlgorithmType HashAlgorithm {
get { return Impl.HashAlgorithm; }
}
public int HashStrength {
get { return Impl.HashStrength; }
}
public ExchangeAlgorithmType KeyExchangeAlgorithm {
get { return Impl.KeyExchangeAlgorithm; }
}
public int KeyExchangeStrength {
get { return Impl.KeyExchangeStrength; }
}
public bool CanRead {
get { return Impl.CanRead; }
}
public bool CanTimeout {
get { return Impl.CanTimeout; }
}
public bool CanWrite {
get { return Impl.CanWrite; }
}
public long Length {
get { return Impl.Length; }
}
public long Position {
get { return Impl.Position; }
}
public void SetLength (long value)
{
Impl.SetLength (value);
}
public AuthenticatedStream AuthenticatedStream {
get { return Impl.AuthenticatedStream; }
}
public int ReadTimeout {
get { return Impl.ReadTimeout; }
set { Impl.ReadTimeout = value; }
}
public int WriteTimeout {
get { return Impl.WriteTimeout; }
set { Impl.WriteTimeout = value; }
}
public bool CheckCertRevocationStatus {
get { return Impl.CheckCertRevocationStatus; }
}
public X509Certificate InternalLocalCertificate {
get { return Impl.InternalLocalCertificate; }
}
public X509Certificate LocalCertificate {
get { return Impl.LocalCertificate; }
}
public X509Certificate RemoteCertificate {
get { return Impl.RemoteCertificate; }
}
public SslProtocols SslProtocol {
get { return Impl.SslProtocol; }
}
public MSI.MonoTlsProvider Provider {
get { return Impl.Provider; }
}
public MSI.MonoTlsConnectionInfo GetConnectionInfo ()
{
return Impl.GetConnectionInfo ();
}
void CheckDisposed ()
{
if (impl == null)
throw new ObjectDisposedException ("MonoSslStream");
}
public void Dispose ()
{
Dispose (true);
GC.SuppressFinalize (this);
}
protected virtual void Dispose (bool disposing)
{
if (impl != null && disposing) {
impl.Dispose ();
impl = null;
}
}
}
}
#endif

Some files were not shown because too many files have changed in this diff Show More