Imported Upstream version 4.8.0.425

Former-commit-id: 56934f10a9ad11e3eb75c21da859e02f54766140
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-01-09 11:04:53 +00:00
parent 693afccc61
commit 2927bc3cc3
47 changed files with 479 additions and 354 deletions

View File

@@ -154,12 +154,9 @@ namespace Mono.Btls
}
}
Exception GetException (MonoBtlsSslError status)
static Exception GetException (MonoBtlsSslError status)
{
var error = MonoBtlsError.GetError ();
if (error == null)
return new MonoBtlsException (status);
var text = MonoBtlsError.GetErrorString (error);
return new MonoBtlsException ("{0} {1}", status, text);
}

View File

@@ -45,12 +45,14 @@ namespace Mono.Btls
static class MonoBtlsX509StoreManager
{
static bool initialized;
#if !ANDROID
static string machineTrustedRootPath;
static string machineIntermediateCAPath;
static string machineUntrustedPath;
static string userTrustedRootPath;
static string userIntermediateCAPath;
static string userUntrustedPath;
#endif
static void Initialize ()
{
@@ -75,9 +77,9 @@ namespace Mono.Btls
userUntrustedPath = Path.Combine (userPath, MX.X509Stores.Names.Untrusted);
var machinePath = MX.X509StoreManager.NewLocalMachinePath;
machineTrustedRootPath = Path.Combine (userPath, MX.X509Stores.Names.TrustedRoot);
machineIntermediateCAPath = Path.Combine (userPath, MX.X509Stores.Names.IntermediateCA);
machineUntrustedPath = Path.Combine (userPath, MX.X509Stores.Names.Untrusted);
machineTrustedRootPath = Path.Combine (machinePath, MX.X509Stores.Names.TrustedRoot);
machineIntermediateCAPath = Path.Combine (machinePath, MX.X509Stores.Names.IntermediateCA);
machineUntrustedPath = Path.Combine (machinePath, MX.X509Stores.Names.Untrusted);
#endif
}

View File

@@ -153,16 +153,23 @@ namespace Mono.Net.Security
}
}
const string LegacyProviderTypeName = "Mono.Net.Security.LegacyTlsProvider";
const string BtlsProviderTypeName = "Mono.Btls.MonoBtlsProvider";
static void InitializeProviderRegistration ()
{
lock (locker) {
if (providerRegistration != null)
return;
providerRegistration = new Dictionary<string,string> ();
providerRegistration.Add ("legacy", "Mono.Net.Security.LegacyTlsProvider");
providerRegistration.Add ("default", "Mono.Net.Security.LegacyTlsProvider");
if (IsBtlsSupported ())
providerRegistration.Add ("btls", "Mono.Btls.MonoBtlsProvider");
providerRegistration.Add ("legacy", LegacyProviderTypeName);
bool btls_supported = IsBtlsSupported ();
if (btls_supported)
providerRegistration.Add ("btls", BtlsProviderTypeName);
providerRegistration.Add ("default", btls_supported && !Platform.IsMacOS ? BtlsProviderTypeName : LegacyProviderTypeName);
X509Helper2.Initialize ();
}
}

View File

@@ -361,7 +361,7 @@ namespace System.Net
return host;
}
if (!HasTimedOut)
if (!HasTimedOut && host != null)
return host;
lastDnsResolve = DateTime.UtcNow;

View File

@@ -17,7 +17,14 @@ namespace MonoTests.System.Net.WebSockets
public class ClientWebSocketTest
{
const string EchoServerUrl = "ws://corefx-net.cloudapp.net/WebSocket/EchoWebSocket.ashx";
int Port = NetworkHelpers.FindFreePort ();
int port;
int Port {
get {
if (port == 0)
port = NetworkHelpers.FindFreePort ();
return port;
}
}
HttpListener _listener;
HttpListener listener {
get {
@@ -158,7 +165,12 @@ namespace MonoTests.System.Net.WebSockets
Assert.AreEqual (WebSocketState.Closed, socket.State);
}
[Test, ExpectedException (typeof (InvalidOperationException))]
[Test]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#else
[ExpectedException (typeof (InvalidOperationException))]
#endif
public void SendAsyncArgTest_NotConnected ()
{
socket.SendAsync (new ArraySegment<byte> (new byte[0]), WebSocketMessageType.Text, true, CancellationToken.None);
@@ -172,7 +184,11 @@ namespace MonoTests.System.Net.WebSockets
socket.SendAsync (new ArraySegment<byte> (), WebSocketMessageType.Text, true, CancellationToken.None);
}
[Test, ExpectedException (typeof (InvalidOperationException))]
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#else
[ExpectedException (typeof (InvalidOperationException))]
#endif
public void ReceiveAsyncArgTest_NotConnected ()
{
socket.ReceiveAsync (new ArraySegment<byte> (new byte[0]), CancellationToken.None);