зеркало из https://github.com/mono/mono-tls.git
Kill more dead code; these entire projects will eventually go away.
This commit is contained in:
Родитель
0d145d9d82
Коммит
dd831ba60c
|
@ -36,6 +36,7 @@ using System.Security.Authentication;
|
|||
using System.Security.Cryptography.X509Certificates;
|
||||
using Mono.Security.NewTls;
|
||||
using Mono.Security.NewTls.TestFramework;
|
||||
using Mono.Security.NewTls.TestProvider;
|
||||
using Xamarin.AsyncTests;
|
||||
|
||||
namespace Mono.Security.Instrumentation.Console
|
||||
|
@ -44,8 +45,12 @@ namespace Mono.Security.Instrumentation.Console
|
|||
|
||||
public abstract class DotNetConnection : Connection, ICommonConnection
|
||||
{
|
||||
public override bool SupportsCleanShutdown {
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public DotNetConnection (ConnectionFactory factory, IPEndPoint endpoint, IConnectionParameters parameters)
|
||||
: base (factory, endpoint, parameters)
|
||||
: base (endpoint, parameters)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -40,8 +40,12 @@ namespace Mono.Security.Instrumentation.Console
|
|||
|
||||
public abstract class OpenSslConnection : Connection, ICommonConnection
|
||||
{
|
||||
public override bool SupportsCleanShutdown {
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public OpenSslConnection (ConnectionFactory factory, IPEndPoint endpoint, IConnectionParameters parameters)
|
||||
: base (factory, endpoint, parameters)
|
||||
: base (endpoint, parameters)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using Mono.Security.NewTls;
|
||||
using Mono.Security.NewTls.TestFramework;
|
||||
using Mono.Security.NewTls.TestProvider;
|
||||
using Xamarin.AsyncTests;
|
||||
|
||||
namespace Mono.Security.Instrumentation.Framework
|
||||
|
@ -21,8 +22,12 @@ namespace Mono.Security.Instrumentation.Framework
|
|||
get { return client; }
|
||||
}
|
||||
|
||||
public override bool SupportsCleanShutdown {
|
||||
get { return server.SupportsCleanShutdown && client.SupportsCleanShutdown; }
|
||||
}
|
||||
|
||||
public ClientAndServer (ClientAndServerFactory factory, IServer server, IClient client, IClientAndServerParameters parameters)
|
||||
: base (factory, server.EndPoint, parameters)
|
||||
: base (server.EndPoint, parameters)
|
||||
{
|
||||
this.server = server;
|
||||
this.client = client;
|
||||
|
|
|
@ -1,164 +0,0 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using Mono.Security.NewTls;
|
||||
using Mono.Security.NewTls.TestFramework;
|
||||
using Xamarin.AsyncTests;
|
||||
|
||||
namespace Mono.Security.Instrumentation.Framework
|
||||
{
|
||||
public abstract class Connection : IConnection, IDisposable
|
||||
{
|
||||
public ConnectionFactory Factory {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public bool SupportsCleanShutdown {
|
||||
get { return Factory.SupportsCleanShutdown; }
|
||||
}
|
||||
|
||||
public IPEndPoint EndPoint {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
string IConnection.EndPoint {
|
||||
get { return PrintEndPoint (EndPoint); }
|
||||
}
|
||||
|
||||
public IConnectionParameters Parameters {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
protected Connection (ConnectionFactory factory, IPEndPoint endpoint, IConnectionParameters parameters)
|
||||
{
|
||||
Factory = factory;
|
||||
EndPoint = endpoint;
|
||||
Parameters = parameters;
|
||||
}
|
||||
|
||||
protected Connection (ConnectionFactory factory, string endpoint, IConnectionParameters parameters)
|
||||
: this (factory, ParseEndPoint (endpoint), parameters)
|
||||
{
|
||||
}
|
||||
|
||||
static string PrintEndPoint (IPEndPoint endpoint)
|
||||
{
|
||||
return string.Format ("{0}:{1}", endpoint.Address, endpoint.Port);
|
||||
}
|
||||
|
||||
static IPEndPoint ParseEndPoint (string text)
|
||||
{
|
||||
var pos = text.IndexOf (":");
|
||||
if (pos < 0)
|
||||
return new IPEndPoint (IPAddress.Parse (text), 4433);
|
||||
var address = IPAddress.Parse (text.Substring (0, pos));
|
||||
var port = int.Parse (text.Substring (pos + 1));
|
||||
return new IPEndPoint (address, port);
|
||||
}
|
||||
|
||||
public abstract Task Start (TestContext ctx, CancellationToken cancellationToken);
|
||||
|
||||
public abstract Task WaitForConnection ();
|
||||
|
||||
public abstract Task<bool> Shutdown (bool attemptCleanShutdown, bool waitForReply);
|
||||
|
||||
protected abstract void Stop ();
|
||||
|
||||
public abstract TlsConnectionInfo GetConnectionInfo ();
|
||||
|
||||
protected Task FinishedTask {
|
||||
get { return Task.FromResult<object> (null); }
|
||||
}
|
||||
|
||||
protected bool RemoteValidationCallback (bool ok, X509Certificate certificate)
|
||||
{
|
||||
Debug ("REMOTE VALIDATION CALLBACK: {0} {1}", ok, certificate.Subject);
|
||||
|
||||
if (ok)
|
||||
return true;
|
||||
if (!Parameters.VerifyPeerCertificate)
|
||||
return true;
|
||||
if (Parameters.TrustedCA == null)
|
||||
return false;
|
||||
|
||||
var caCert = new X509Certificate (Parameters.TrustedCA.Data);
|
||||
Debug ("Got Trusted CA Certificate: {0}", caCert.Subject);
|
||||
Debug ("Remote Certificate: {0}", certificate.Subject);
|
||||
|
||||
Debug ("Remote Certificate Issuer: {0}", certificate.Issuer);
|
||||
|
||||
return caCert.Subject.Equals (certificate.Issuer);
|
||||
}
|
||||
|
||||
protected X509Certificate LocalCertificateSelectionCallback (string targetHost, X509CertificateCollection localCertificates, X509Certificate remoteCertificate, string[] acceptableIssuers)
|
||||
{
|
||||
Debug ("LOCAL SELECTION CALLBACK: {0}", targetHost);
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void Debug (string message, params object[] args)
|
||||
{
|
||||
if (Parameters.EnableDebugging)
|
||||
Console.WriteLine ("[{0}]: {1}", GetType ().Name, string.Format (message, args));
|
||||
}
|
||||
|
||||
#region ITestInstance implementation
|
||||
|
||||
public async Task Initialize (TestContext ctx, CancellationToken cancellationToken)
|
||||
{
|
||||
ctx.LogMessage ("Initialize: {0}", this);
|
||||
await Start (ctx, cancellationToken);
|
||||
ctx.LogMessage ("Initialize #1: {0}", this);
|
||||
}
|
||||
|
||||
public Task PreRun (TestContext ctx, CancellationToken cancellationToken)
|
||||
{
|
||||
return FinishedTask;
|
||||
}
|
||||
|
||||
public Task PostRun (TestContext ctx, CancellationToken cancellationToken)
|
||||
{
|
||||
return FinishedTask;
|
||||
}
|
||||
|
||||
public Task Destroy (TestContext ctx, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.Run (() => {
|
||||
Dispose ();
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
Dispose (true);
|
||||
GC.SuppressFinalize (this);
|
||||
}
|
||||
|
||||
bool disposed;
|
||||
|
||||
protected virtual void Dispose (bool disposing)
|
||||
{
|
||||
lock (this) {
|
||||
if (disposed)
|
||||
return;
|
||||
disposed = true;
|
||||
}
|
||||
Stop ();
|
||||
}
|
||||
|
||||
~Connection ()
|
||||
{
|
||||
Dispose (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -35,7 +35,6 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Connection.cs" />
|
||||
<Compile Include="ConnectionFactory.cs" />
|
||||
<Compile Include="ClientAndServer.cs" />
|
||||
<Compile Include="ClientParameters.cs" />
|
||||
|
|
|
@ -125,6 +125,10 @@ namespace Mono.Security.NewTls.Tests
|
|||
[ClientTestHost] IClient client)
|
||||
{
|
||||
ctx.LogMessage ("TEST CONNECTION: {0} {1} {2} {3}", serverParameters, clientParameters, server, client);
|
||||
|
||||
await client.WaitForConnection ();
|
||||
ctx.LogMessage ("GOT CLIENT CONNECTION!");
|
||||
|
||||
await Task.Delay (10000);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче