You've already forked linux-packaging-mono
Imported Upstream version 5.8.0.22
Former-commit-id: df344e34b07851d296efb3e6604c8db42b6f7aa3
This commit is contained in:
parent
5f4a27cc8a
commit
7d05485754
@@ -149,7 +149,7 @@ namespace Mono.AppleTls
|
||||
}
|
||||
|
||||
var result = trust.Evaluate ();
|
||||
if (result == SecTrustResult.Unspecified)
|
||||
if (result == SecTrustResult.Unspecified || result == SecTrustResult.Proceed)
|
||||
return true;
|
||||
|
||||
errors |= MonoSslPolicyErrors.RemoteCertificateChainErrors;
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Mono.AppleTls
|
||||
|
||||
GCHandle handle;
|
||||
IntPtr context;
|
||||
IntPtr connectionId;
|
||||
|
||||
SslReadFunc readFunc;
|
||||
SslWriteFunc writeFunc;
|
||||
|
||||
@@ -73,8 +73,7 @@ namespace Mono.AppleTls
|
||||
: base (parent, serverMode, targetHost, enabledProtocols,
|
||||
serverCertificate, clientCertificates, askForClientCert)
|
||||
{
|
||||
handle = GCHandle.Alloc (this);
|
||||
connectionId = GCHandle.ToIntPtr (handle);
|
||||
handle = GCHandle.Alloc (this, GCHandleType.Weak);
|
||||
readFunc = NativeReadCallback;
|
||||
writeFunc = NativeWriteCallback;
|
||||
|
||||
@@ -96,12 +95,6 @@ namespace Mono.AppleTls
|
||||
get { return !disposed && context != IntPtr.Zero; }
|
||||
}
|
||||
|
||||
[System.Diagnostics.Conditional ("APPLE_TLS_DEBUG")]
|
||||
protected new void Debug (string message, params object[] args)
|
||||
{
|
||||
Console.Error.WriteLine ("MobileTlsStream({0}): {1}", Parent.ID, string.Format (message, args));
|
||||
}
|
||||
|
||||
void CheckStatusAndThrow (SslStatus status, params SslStatus[] acceptable)
|
||||
{
|
||||
var last = Interlocked.Exchange (ref lastException, null);
|
||||
@@ -283,7 +276,7 @@ namespace Mono.AppleTls
|
||||
var result = SSLSetIOFuncs (Handle, readFunc, writeFunc);
|
||||
CheckStatusAndThrow (result);
|
||||
|
||||
result = SSLSetConnection (Handle, connectionId);
|
||||
result = SSLSetConnection (Handle, GCHandle.ToIntPtr (handle));
|
||||
CheckStatusAndThrow (result);
|
||||
|
||||
if ((EnabledProtocols & SSA.SslProtocols.Tls) != 0)
|
||||
@@ -300,11 +293,6 @@ namespace Mono.AppleTls
|
||||
else
|
||||
MaxProtocol = SslProtocol.Tls_1_0;
|
||||
|
||||
#if APPLE_TLS_DEBUG
|
||||
foreach (var c in GetSupportedCiphers ())
|
||||
Debug (" {0} SslCipherSuite.{1} {2:x} {3}", IsServer ? "Server" : "Client", c, (int)c, (CipherSuiteCode)c);
|
||||
#endif
|
||||
|
||||
if (Settings != null && Settings.EnabledCiphers != null) {
|
||||
SslCipherSuite [] ciphers = new SslCipherSuite [Settings.EnabledCiphers.Length];
|
||||
for (int i = 0 ; i < Settings.EnabledCiphers.Length; ++i)
|
||||
@@ -693,18 +681,19 @@ namespace Mono.AppleTls
|
||||
[Mono.Util.MonoPInvokeCallback (typeof (SslReadFunc))]
|
||||
static SslStatus NativeReadCallback (IntPtr ptr, IntPtr data, ref IntPtr dataLength)
|
||||
{
|
||||
var handle = GCHandle.FromIntPtr (ptr);
|
||||
if (!handle.IsAllocated)
|
||||
return SslStatus.Internal;
|
||||
|
||||
var context = (AppleTlsContext) handle.Target;
|
||||
if (context.disposed)
|
||||
return SslStatus.ClosedAbort;
|
||||
|
||||
AppleTlsContext context = null;
|
||||
try {
|
||||
var weakHandle = GCHandle.FromIntPtr (ptr);
|
||||
if (!weakHandle.IsAllocated)
|
||||
return SslStatus.Internal;
|
||||
|
||||
context = (AppleTlsContext) weakHandle.Target;
|
||||
if (context == null || context.disposed)
|
||||
return SslStatus.ClosedAbort;
|
||||
|
||||
return context.NativeReadCallback (data, ref dataLength);
|
||||
} catch (Exception ex) {
|
||||
if (context.lastException == null)
|
||||
if (context != null && context.lastException == null)
|
||||
context.lastException = ex;
|
||||
return SslStatus.Internal;
|
||||
}
|
||||
@@ -713,18 +702,19 @@ namespace Mono.AppleTls
|
||||
[Mono.Util.MonoPInvokeCallback (typeof (SslWriteFunc))]
|
||||
static SslStatus NativeWriteCallback (IntPtr ptr, IntPtr data, ref IntPtr dataLength)
|
||||
{
|
||||
var handle = GCHandle.FromIntPtr (ptr);
|
||||
if (!handle.IsAllocated)
|
||||
return SslStatus.Internal;
|
||||
|
||||
var context = (AppleTlsContext) handle.Target;
|
||||
if (context.disposed)
|
||||
return SslStatus.ClosedAbort;
|
||||
|
||||
AppleTlsContext context = null;
|
||||
try {
|
||||
var weakHandle = GCHandle.FromIntPtr (ptr);
|
||||
if (!weakHandle.IsAllocated)
|
||||
return SslStatus.Internal;
|
||||
|
||||
context = (AppleTlsContext) weakHandle.Target;
|
||||
if (context == null || context.disposed)
|
||||
return SslStatus.ClosedAbort;
|
||||
|
||||
return context.NativeWriteCallback (data, ref dataLength);
|
||||
} catch (Exception ex) {
|
||||
if (context.lastException == null)
|
||||
if (context != null && context.lastException == null)
|
||||
context.lastException = ex;
|
||||
return SslStatus.Internal;
|
||||
}
|
||||
@@ -785,7 +775,7 @@ namespace Mono.AppleTls
|
||||
[DllImport (SecurityLibrary)]
|
||||
extern unsafe static /* OSStatus */ SslStatus SSLRead (/* SSLContextRef */ IntPtr context, /* const void* */ byte* data, /* size_t */ IntPtr dataLength, /* size_t* */ out IntPtr processed);
|
||||
|
||||
public override unsafe int Read (byte[] buffer, int offset, int count, out bool wantMore)
|
||||
public override unsafe (int ret, bool wantMore) Read (byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (Interlocked.Exchange (ref pendingIO, 1) == 1)
|
||||
throw new InvalidOperationException ();
|
||||
@@ -809,13 +799,12 @@ namespace Mono.AppleTls
|
||||
* when the first inner Read() returns 0. MobileAuthenticatedStream.InnerRead() attempts
|
||||
* to distinguish between a graceful close and abnormal termination of connection.
|
||||
*/
|
||||
wantMore = false;
|
||||
return 0;
|
||||
return (0, false);
|
||||
}
|
||||
|
||||
CheckStatusAndThrow (status, SslStatus.WouldBlock, SslStatus.ClosedGraceful);
|
||||
wantMore = status == SslStatus.WouldBlock;
|
||||
return (int)processed;
|
||||
var wantMore = status == SslStatus.WouldBlock;
|
||||
return ((int)processed, wantMore);
|
||||
} catch (Exception ex) {
|
||||
Debug ("Read error: {0}", ex);
|
||||
throw;
|
||||
@@ -827,7 +816,7 @@ namespace Mono.AppleTls
|
||||
[DllImport (SecurityLibrary)]
|
||||
extern unsafe static /* OSStatus */ SslStatus SSLWrite (/* SSLContextRef */ IntPtr context, /* const void* */ byte* data, /* size_t */ IntPtr dataLength, /* size_t* */ out IntPtr processed);
|
||||
|
||||
public override unsafe int Write (byte[] buffer, int offset, int count, out bool wantMore)
|
||||
public override unsafe (int ret, bool wantMore) Write (byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (Interlocked.Exchange (ref pendingIO, 1) == 1)
|
||||
throw new InvalidOperationException ();
|
||||
@@ -847,8 +836,8 @@ namespace Mono.AppleTls
|
||||
|
||||
CheckStatusAndThrow (status, SslStatus.WouldBlock);
|
||||
|
||||
wantMore = status == SslStatus.WouldBlock;
|
||||
return (int)processed;
|
||||
var wantMore = status == SslStatus.WouldBlock;
|
||||
return ((int)processed, wantMore);
|
||||
} finally {
|
||||
pendingIO = 0;
|
||||
}
|
||||
@@ -859,24 +848,7 @@ namespace Mono.AppleTls
|
||||
|
||||
public override void Shutdown ()
|
||||
{
|
||||
if (Interlocked.Exchange (ref pendingIO, 1) == 1)
|
||||
throw new InvalidOperationException ();
|
||||
|
||||
Debug ("Shutdown");
|
||||
|
||||
lastException = null;
|
||||
|
||||
try {
|
||||
if (closed || disposed)
|
||||
return;
|
||||
|
||||
var status = SSLClose (Handle);
|
||||
Debug ("Shutdown done: {0}", status);
|
||||
CheckStatusAndThrow (status);
|
||||
} finally {
|
||||
closed = true;
|
||||
pendingIO = 0;
|
||||
}
|
||||
closed = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -65,6 +65,10 @@ namespace Mono.AppleTls
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
internal override bool SupportsCleanShutdown {
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override SslProtocols SupportedProtocols {
|
||||
get { return SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls; }
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ namespace Mono.Btls
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public override int Read (byte[] buffer, int offset, int size, out bool wantMore)
|
||||
public override (int ret, bool wantMore) Read (byte[] buffer, int offset, int size)
|
||||
{
|
||||
Debug ("Read: {0} {1} {2}", buffer.Length, offset, size);
|
||||
|
||||
@@ -313,27 +313,23 @@ namespace Mono.Btls
|
||||
var status = ssl.Read (data, ref size);
|
||||
Debug ("Read done: {0} {1}", status, size);
|
||||
|
||||
if (status == MonoBtlsSslError.WantRead) {
|
||||
wantMore = true;
|
||||
return 0;
|
||||
} else if (status == MonoBtlsSslError.ZeroReturn) {
|
||||
wantMore = false;
|
||||
return size;
|
||||
} else if (status != MonoBtlsSslError.None) {
|
||||
if (status == MonoBtlsSslError.WantRead)
|
||||
return (0, true);
|
||||
if (status == MonoBtlsSslError.ZeroReturn)
|
||||
return (size, false);
|
||||
if (status != MonoBtlsSslError.None)
|
||||
throw GetException (status);
|
||||
}
|
||||
|
||||
if (size > 0)
|
||||
Marshal.Copy (data, buffer, offset, size);
|
||||
|
||||
wantMore = false;
|
||||
return size;
|
||||
return (size, false);
|
||||
} finally {
|
||||
Marshal.FreeHGlobal (data);
|
||||
}
|
||||
}
|
||||
|
||||
public override int Write (byte[] buffer, int offset, int size, out bool wantMore)
|
||||
public override (int ret, bool wantMore) Write (byte[] buffer, int offset, int size)
|
||||
{
|
||||
Debug ("Write: {0} {1} {2}", buffer.Length, offset, size);
|
||||
|
||||
@@ -347,15 +343,12 @@ namespace Mono.Btls
|
||||
var status = ssl.Write (data, ref size);
|
||||
Debug ("Write done: {0} {1}", status, size);
|
||||
|
||||
if (status == MonoBtlsSslError.WantWrite) {
|
||||
wantMore = true;
|
||||
return 0;
|
||||
} else if (status != MonoBtlsSslError.None) {
|
||||
if (status == MonoBtlsSslError.WantWrite)
|
||||
return (0, true);
|
||||
if (status != MonoBtlsSslError.None)
|
||||
throw GetException (status);
|
||||
}
|
||||
|
||||
wantMore = false;
|
||||
return size;
|
||||
return (size, false);
|
||||
} finally {
|
||||
Marshal.FreeHGlobal (data);
|
||||
}
|
||||
@@ -364,7 +357,8 @@ namespace Mono.Btls
|
||||
public override void Shutdown ()
|
||||
{
|
||||
Debug ("Shutdown!");
|
||||
// ssl.SetQuietShutdown ();
|
||||
if (Settings == null || !Settings.SendCloseNotify)
|
||||
ssl.SetQuietShutdown ();
|
||||
ssl.Shutdown ();
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,10 @@ namespace Mono.Btls
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
internal override bool SupportsCleanShutdown {
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override SslProtocols SupportedProtocols {
|
||||
get { return SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls; }
|
||||
}
|
||||
|
||||
@@ -130,6 +130,12 @@ namespace Mono.Btls
|
||||
[DllImport (BTLS_DYLIB)]
|
||||
extern static IntPtr mono_btls_ssl_get_server_name (IntPtr handle);
|
||||
|
||||
[DllImport (BTLS_DYLIB)]
|
||||
extern static void mono_btls_ssl_set_renegotiate_mode (IntPtr handle, int mode);
|
||||
|
||||
[DllImport (BTLS_DYLIB)]
|
||||
extern static int mono_btls_ssl_renegotiate_pending (IntPtr handle);
|
||||
|
||||
static BoringSslHandle Create_internal (MonoBtlsSslCtx ctx)
|
||||
{
|
||||
var handle = mono_btls_ssl_new (ctx.Handle.DangerousGetHandle ());
|
||||
@@ -448,6 +454,17 @@ namespace Mono.Btls
|
||||
if (!Handle.IsInvalid)
|
||||
mono_btls_ssl_close (Handle.DangerousGetHandle ());
|
||||
}
|
||||
|
||||
public void SetRenegotiateMode (MonoBtlsSslRenegotiateMode mode)
|
||||
{
|
||||
CheckThrow ();
|
||||
mono_btls_ssl_set_renegotiate_mode (Handle.DangerousGetHandle (), (int)mode);
|
||||
}
|
||||
|
||||
public bool RenegotiatePending ()
|
||||
{
|
||||
return mono_btls_ssl_renegotiate_pending (Handle.DangerousGetHandle ()) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
39
mcs/class/System/Mono.Btls/MonoBtlsSslRenegotiateMode.cs
Normal file
39
mcs/class/System/Mono.Btls/MonoBtlsSslRenegotiateMode.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// MonoBtlsSslRenegotiateMode.cs
|
||||
//
|
||||
// Author:
|
||||
// Martin Baulig <mabaul@microsoft.com>
|
||||
//
|
||||
// Copyright (c) 2017 Xamarin Inc. (http://www.xamarin.com)
|
||||
//
|
||||
// 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 && MONO_FEATURE_BTLS
|
||||
using System;
|
||||
namespace Mono.Btls
|
||||
{
|
||||
[Flags]
|
||||
enum MonoBtlsSslRenegotiateMode
|
||||
{
|
||||
NEVER = 0,
|
||||
ONCE,
|
||||
FREELY,
|
||||
IGNORE
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -303,6 +303,8 @@ namespace Mono.Btls
|
||||
return PKCS8.PrivateKeyInfo.DecodeRSA (bytes);
|
||||
}
|
||||
set {
|
||||
if (nativePrivateKey != null)
|
||||
nativePrivateKey.Dispose ();
|
||||
nativePrivateKey = null;
|
||||
FallbackImpl.PrivateKey = value;
|
||||
}
|
||||
@@ -490,6 +492,7 @@ namespace Mono.Btls
|
||||
x509 = null;
|
||||
}
|
||||
if (nativePrivateKey != null) {
|
||||
nativePrivateKey.Dispose ();
|
||||
nativePrivateKey = null;
|
||||
}
|
||||
subjectName = null;
|
||||
|
||||
@@ -158,7 +158,7 @@ namespace Mono.Net.Security
|
||||
RunSynchronously = sync;
|
||||
}
|
||||
|
||||
[SD.Conditional ("MARTIN_DEBUG")]
|
||||
[SD.Conditional ("MONO_TLS_DEBUG")]
|
||||
protected void Debug (string message, params object[] args)
|
||||
{
|
||||
Parent.Debug ("{0}({1}:{2}): {3}", Name, Parent.ID, ID, string.Format (message, args));
|
||||
@@ -226,6 +226,7 @@ namespace Mono.Net.Security
|
||||
|
||||
if (Interlocked.Exchange (ref WriteRequested, 0) != 0) {
|
||||
// Flush the write queue.
|
||||
Debug ("ProcessOperation - flushing write queue");
|
||||
await Parent.InnerWrite (RunSynchronously, cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,10 @@ namespace Mono.Net.Security
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
internal override bool SupportsCleanShutdown {
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override SslProtocols SupportedProtocols {
|
||||
get { return SslProtocols.Tls; }
|
||||
}
|
||||
|
||||
@@ -384,10 +384,10 @@ namespace Mono.Net.Security
|
||||
static int nextId;
|
||||
internal readonly int ID = ++nextId;
|
||||
|
||||
[SD.Conditional ("MARTIN_DEBUG")]
|
||||
[SD.Conditional ("MONO_TLS_DEBUG")]
|
||||
protected internal void Debug (string message, params object[] args)
|
||||
{
|
||||
Console.Error.WriteLine ("MobileAuthenticatedStream({0}): {1}", ID, string.Format (message, args));
|
||||
MonoTlsProviderFactory.Debug ("MobileAuthenticatedStream({0}): {1}", ID, string.Format (message, args));
|
||||
}
|
||||
|
||||
#region Called back from native code via SslConnection
|
||||
@@ -531,7 +531,7 @@ namespace Mono.Net.Security
|
||||
internal async Task<int> InnerRead (bool sync, int requestedSize, CancellationToken cancellationToken)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested ();
|
||||
Debug ("InnerRead: {0} {1} {2} {3}", readBuffer.Offset, readBuffer.Size, readBuffer.Remaining, requestedSize);
|
||||
Debug ("InnerRead: {0} {1} {2} {3} {4}", sync, readBuffer.Offset, readBuffer.Size, readBuffer.Remaining, requestedSize);
|
||||
|
||||
var len = System.Math.Min (readBuffer.Remaining, requestedSize);
|
||||
if (len == 0)
|
||||
@@ -612,11 +612,16 @@ namespace Mono.Net.Security
|
||||
* SSLHandshake() will return repeatedly with 'SslStatus.WouldBlock', we then need
|
||||
* to take care of I/O and call it again.
|
||||
*/
|
||||
var newStatus = AsyncOperationStatus.Continue;
|
||||
if (xobileTlsContext.ProcessHandshake ()) {
|
||||
xobileTlsContext.FinishHandshake ();
|
||||
return AsyncOperationStatus.Complete;
|
||||
newStatus = AsyncOperationStatus.Complete;
|
||||
}
|
||||
return AsyncOperationStatus.Continue;
|
||||
|
||||
if (lastException != null)
|
||||
lastException.Throw ();
|
||||
|
||||
return newStatus;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -624,8 +629,10 @@ namespace Mono.Net.Security
|
||||
{
|
||||
lock (ioLock) {
|
||||
// This operates on the internal buffer and will never block.
|
||||
var ret = xobileTlsContext.Read (userBuffer.Buffer, userBuffer.Offset, userBuffer.Size, out bool wantMore);
|
||||
return (ret, wantMore);
|
||||
var ret = xobileTlsContext.Read (userBuffer.Buffer, userBuffer.Offset, userBuffer.Size);
|
||||
if (lastException != null)
|
||||
lastException.Throw ();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -633,8 +640,10 @@ namespace Mono.Net.Security
|
||||
{
|
||||
lock (ioLock) {
|
||||
// This operates on the internal buffer and will never block.
|
||||
var ret = xobileTlsContext.Write (userBuffer.Buffer, userBuffer.Offset, userBuffer.Size, out bool wantMore);
|
||||
return (ret, wantMore);
|
||||
var ret = xobileTlsContext.Write (userBuffer.Buffer, userBuffer.Offset, userBuffer.Size);
|
||||
if (lastException != null)
|
||||
lastException.Throw ();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -698,7 +707,7 @@ namespace Mono.Net.Security
|
||||
|
||||
public override void Flush ()
|
||||
{
|
||||
// Write() automatically flushes the underlying stream.
|
||||
InnerStream.Flush ();
|
||||
}
|
||||
|
||||
public SslProtocols SslProtocol {
|
||||
|
||||
@@ -78,10 +78,10 @@ namespace Mono.Net.Security
|
||||
get { return parent.Provider; }
|
||||
}
|
||||
|
||||
[SD.Conditional ("MARTIN_DEBUG")]
|
||||
[SD.Conditional ("MONO_TLS_DEBUG")]
|
||||
protected void Debug (string message, params object[] args)
|
||||
{
|
||||
Console.Error.WriteLine ("{0}: {1}", GetType ().Name, string.Format (message, args));
|
||||
parent.Debug ("{0}: {1}", GetType ().Name, string.Format (message, args));
|
||||
}
|
||||
|
||||
public abstract bool HasContext {
|
||||
@@ -165,9 +165,9 @@ namespace Mono.Net.Security
|
||||
|
||||
public abstract void Flush ();
|
||||
|
||||
public abstract int Read (byte[] buffer, int offset, int count, out bool wantMore);
|
||||
public abstract (int ret, bool wantMore) Read (byte[] buffer, int offset, int count);
|
||||
|
||||
public abstract int Write (byte[] buffer, int offset, int count, out bool wantMore);
|
||||
public abstract (int ret, bool wantMore) Write (byte[] buffer, int offset, int count);
|
||||
|
||||
public abstract void Shutdown ();
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
@@ -192,6 +193,22 @@ namespace Mono.Net.Security
|
||||
}
|
||||
}
|
||||
|
||||
static bool enableDebug;
|
||||
|
||||
[Conditional ("MONO_TLS_DEBUG")]
|
||||
static void InitializeDebug ()
|
||||
{
|
||||
if (Environment.GetEnvironmentVariable ("MONO_TLS_DEBUG") != null)
|
||||
enableDebug = true;
|
||||
}
|
||||
|
||||
[Conditional ("MONO_TLS_DEBUG")]
|
||||
internal static void Debug (string message, params object[] args)
|
||||
{
|
||||
if (enableDebug)
|
||||
Console.Error.WriteLine (message, args);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
internal static readonly Guid AppleTlsId = new Guid ("981af8af-a3a3-419a-9f01-a518e3a17c1c");
|
||||
@@ -203,6 +220,9 @@ namespace Mono.Net.Security
|
||||
lock (locker) {
|
||||
if (providerRegistration != null)
|
||||
return;
|
||||
|
||||
InitializeDebug ();
|
||||
|
||||
providerRegistration = new Dictionary<string,Tuple<Guid,string>> ();
|
||||
providerCache = new Dictionary<Guid,MSI.MonoTlsProvider> ();
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Net.Security;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Security.Authentication;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
@@ -56,6 +57,8 @@ namespace Mono.Net.Security
|
||||
readonly NetworkStream networkStream;
|
||||
readonly HttpWebRequest request;
|
||||
|
||||
readonly MonoTlsSettings settings;
|
||||
|
||||
internal HttpWebRequest Request {
|
||||
get { return request; }
|
||||
}
|
||||
@@ -65,6 +68,8 @@ namespace Mono.Net.Security
|
||||
internal IMonoSslStream SslStream {
|
||||
get { return sslStream; }
|
||||
}
|
||||
#else
|
||||
const string EXCEPTION_MESSAGE = "System.Net.Security.SslStream is not supported on the current platform.";
|
||||
#endif
|
||||
|
||||
WebExceptionStatus status;
|
||||
@@ -77,12 +82,9 @@ namespace Mono.Net.Security
|
||||
get; set;
|
||||
}
|
||||
|
||||
#if SECURITY_DEP
|
||||
// readonly ChainValidationHelper validationHelper;
|
||||
readonly MonoTlsSettings settings;
|
||||
|
||||
public MonoTlsStream (HttpWebRequest request, NetworkStream networkStream)
|
||||
{
|
||||
#if SECURITY_DEP
|
||||
this.request = request;
|
||||
this.networkStream = networkStream;
|
||||
|
||||
@@ -90,11 +92,16 @@ namespace Mono.Net.Security
|
||||
provider = request.TlsProvider ?? MonoTlsProviderFactory.GetProviderInternal ();
|
||||
status = WebExceptionStatus.SecureChannelFailure;
|
||||
|
||||
/*validationHelper =*/ ChainValidationHelper.Create (provider, ref settings, this);
|
||||
ChainValidationHelper.Create (provider, ref settings, this);
|
||||
#else
|
||||
status = WebExceptionStatus.SecureChannelFailure;
|
||||
throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
|
||||
#endif
|
||||
}
|
||||
|
||||
internal Stream CreateStream (byte[] buffer)
|
||||
{
|
||||
#if SECURITY_DEP
|
||||
sslStream = provider.CreateSslStream (networkStream, false, settings);
|
||||
|
||||
try {
|
||||
@@ -111,7 +118,7 @@ namespace Mono.Net.Security
|
||||
ServicePointManager.CheckCertificateRevocationList);
|
||||
|
||||
status = WebExceptionStatus.Success;
|
||||
} catch (Exception) {
|
||||
} catch {
|
||||
status = WebExceptionStatus.SecureChannelFailure;
|
||||
throw;
|
||||
} finally {
|
||||
@@ -136,7 +143,9 @@ namespace Mono.Net.Security
|
||||
}
|
||||
|
||||
return sslStream.AuthenticatedStream;
|
||||
}
|
||||
#else
|
||||
throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
83404914b3bd686a8fb10da985249e69631c4de7
|
||||
a18b9fba8f695be595e34687b92949f3dd80fb69
|
||||
@@ -482,7 +482,8 @@ namespace System.Diagnostics
|
||||
if (proc == IntPtr.Zero)
|
||||
throw new ArgumentException ("Can't find process with ID " + processId.ToString ());
|
||||
|
||||
return (new Process (new SafeProcessHandle (proc, false), processId));
|
||||
/* The handle returned by GetProcess_internal is owned by its caller, so we must pass true to SafeProcessHandle */
|
||||
return (new Process (new SafeProcessHandle (proc, true), processId));
|
||||
}
|
||||
|
||||
public static Process[] GetProcessesByName(string processName, string machineName)
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace System.IO {
|
||||
data = (DefaultWatcherData) watches [fsw];
|
||||
if (data != null) {
|
||||
data.Enabled = false;
|
||||
data.DisabledTime = DateTime.Now;
|
||||
data.DisabledTime = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -171,7 +171,7 @@ namespace System.IO {
|
||||
{
|
||||
if (!data.Enabled) {
|
||||
return (data.DisabledTime != DateTime.MaxValue &&
|
||||
(DateTime.Now - data.DisabledTime).TotalSeconds > 5);
|
||||
(DateTime.UtcNow - data.DisabledTime).TotalSeconds > 5);
|
||||
}
|
||||
|
||||
DoFiles (data, data.Directory, dispatch);
|
||||
|
||||
@@ -307,8 +307,6 @@ namespace System.Net.NetworkInformation {
|
||||
} else if (sockaddr.sin_family == AF_PACKET) {
|
||||
sockaddr_ll sockaddrll = (sockaddr_ll) Marshal.PtrToStructure (addr.ifa_addr, typeof (sockaddr_ll));
|
||||
if (((int)sockaddrll.sll_halen) > sockaddrll.sll_addr.Length){
|
||||
Console.Error.WriteLine ("Got a bad hardware address length for an AF_PACKET {0} {1}",
|
||||
sockaddrll.sll_halen, sockaddrll.sll_addr.Length);
|
||||
next = addr.ifa_next;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -76,9 +76,8 @@ namespace System.Net.NetworkInformation {
|
||||
const int default_timeout = 4000; // 4 sec.
|
||||
ushort identifier;
|
||||
|
||||
// This value is correct as of Linux kernel version 2.6.25.9
|
||||
// See /usr/include/linux/capability.h
|
||||
const UInt32 linux_cap_version = 0x20071026;
|
||||
// Request 32-bit capabilities by using version 1
|
||||
const UInt32 _LINUX_CAPABILITY_VERSION_1 = 0x19980330;
|
||||
|
||||
static readonly byte [] default_buffer = new byte [0];
|
||||
|
||||
@@ -132,7 +131,7 @@ namespace System.Net.NetworkInformation {
|
||||
cap_user_header_t header = new cap_user_header_t ();
|
||||
cap_user_data_t data = new cap_user_data_t ();
|
||||
|
||||
header.version = linux_cap_version;
|
||||
header.version = _LINUX_CAPABILITY_VERSION_1;
|
||||
|
||||
int ret = -1;
|
||||
|
||||
@@ -247,7 +246,7 @@ namespace System.Net.NetworkInformation {
|
||||
s.SendBufferSize = bytes.Length;
|
||||
s.SendTo (bytes, bytes.Length, SocketFlags.None, target);
|
||||
|
||||
DateTime sentTime = DateTime.Now;
|
||||
var sw = Stopwatch.StartNew ();
|
||||
|
||||
// receive
|
||||
bytes = new byte [100];
|
||||
@@ -263,7 +262,7 @@ namespace System.Net.NetworkInformation {
|
||||
}
|
||||
throw new NotSupportedException (String.Format ("Unexpected socket error during ping request: {0}", error));
|
||||
}
|
||||
long rtt = (long) (DateTime.Now - sentTime).TotalMilliseconds;
|
||||
long rtt = (long) sw.ElapsedMilliseconds;
|
||||
int headerLength = (bytes [0] & 0xF) << 2;
|
||||
int bodyLength = rc - headerLength;
|
||||
|
||||
@@ -295,7 +294,7 @@ namespace System.Net.NetworkInformation {
|
||||
private PingReply SendUnprivileged (IPAddress address, int timeout, byte [] buffer, PingOptions options)
|
||||
{
|
||||
#if MONO_FEATURE_PROCESS_START
|
||||
DateTime sentTime = DateTime.UtcNow;
|
||||
var sw = Stopwatch.StartNew ();
|
||||
|
||||
Process ping = new Process ();
|
||||
string args = BuildPingArgs (address, timeout, options);
|
||||
@@ -319,7 +318,7 @@ namespace System.Net.NetworkInformation {
|
||||
string stderr = ping.StandardError.ReadToEnd ();
|
||||
#pragma warning restore 219
|
||||
|
||||
trip_time = (long) (DateTime.UtcNow - sentTime).TotalMilliseconds;
|
||||
trip_time = (long) sw.ElapsedMilliseconds;
|
||||
if (!ping.WaitForExit (timeout) || (ping.HasExited && ping.ExitCode == 2))
|
||||
status = IPStatus.TimedOut;
|
||||
else if (ping.ExitCode == 0)
|
||||
|
||||
@@ -293,15 +293,15 @@ namespace System.Net.Security
|
||||
}
|
||||
|
||||
public override bool CanRead {
|
||||
get { return Impl.CanRead; }
|
||||
get { return impl != null && impl.CanRead; }
|
||||
}
|
||||
|
||||
public override bool CanTimeout {
|
||||
get { return Impl.CanTimeout; }
|
||||
get { return InnerStream.CanTimeout; }
|
||||
}
|
||||
|
||||
public override bool CanWrite {
|
||||
get { return Impl.CanWrite; }
|
||||
get { return impl != null && impl.CanWrite; }
|
||||
}
|
||||
|
||||
public override int ReadTimeout {
|
||||
@@ -337,7 +337,7 @@ namespace System.Net.Security
|
||||
|
||||
public override void Flush ()
|
||||
{
|
||||
Impl.Flush ();
|
||||
InnerStream.Flush ();
|
||||
}
|
||||
|
||||
void CheckDisposed ()
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user