- Made a polciy thing to try follow their example as close as possible, big mmmmh moment

This commit is contained in:
Tristan B. Velloza Kildaire 2023-04-29 22:37:34 +02:00
parent 70053118af
commit 3199a4e394
3 changed files with 31 additions and 3 deletions

View File

@ -29,7 +29,9 @@ public class CryptClient : RiverStream
// TODO: Setup
private TLSSessionManager sessionManager = new TLSSessionManagerNoop();
private TLSCredentialsManager credentialManager;
private TLSPolicy policy = new TLSPolicy();
import cryptstream.streams.testingPolicy;
private TLSPolicy policy = new TestingPolicy();
private RandomNumberGenerator rng;
/**
@ -42,6 +44,7 @@ public class CryptClient : RiverStream
this.stream = stream;
this.rng = RandomNumberGenerator.makeRng();
// this.sessionManager = new TLSSessionManagerInMemory(rng);
import cryptstream.streams.credmanager : CredManager;
this.credentialManager = new CredManager();
@ -196,7 +199,7 @@ unittest
/**
* Setup a server
*/
Address addr = parseAddress("::1", 7057);
Address addr = parseAddress("::1", 1214);
writeln("Binding server to: ", addr);
Server server = new Server(addr);
server.start();
@ -211,6 +214,8 @@ unittest
CryptClient client = new CryptClient(stream);
Thread.sleep(dur!("seconds")(3));
// FIXME: This crashes as handshake doens't go through meaning the `isActive()` is false
client.writeFully(cast(byte[])"ABBA");

View File

@ -15,7 +15,8 @@ public class CryptServerHandle
// TODO: Setup
private TLSSessionManager sessionManager = new TLSSessionManagerNoop();
private TLSCredentialsManager credentialManager;
private TLSPolicy policy = new TLSPolicy();
import cryptstream.streams.testingPolicy;
private TLSPolicy policy = new TestingPolicy();
private RandomNumberGenerator rng;
/**
@ -31,6 +32,8 @@ public class CryptServerHandle
writeln("HOL");
this.rng = RandomNumberGenerator.makeRng();
// this.sessionManager = new TLSSessionManagerInMemory(rng);
import cryptstream.streams.credmanager : CredManager;
this.credentialManager = new CredManager();
this.clientSocket = clientSocket;
@ -78,6 +81,9 @@ public class CryptServerHandle
private bool tlsHandshakeHandler(in TLSSession session)
{
// TODO: Implement me
import std.stdio;
writeln("tlsHandshakeHandler(server-side) Hello handshake came in?");
return true;
}

View File

@ -0,0 +1,17 @@
module cryptstream.streams.testingPolicy;
import botan.tls.policy : TLSPolicy;
import botan.tls.client : TLSProtocolVersion;
public class TestingPolicy : TLSPolicy
{
public override const bool acceptableProtocolVersion(TLSProtocolVersion _version)
{
return true;
}
public override const bool sendFallbackSCSV(in TLSProtocolVersion _version)
{
return false;
}
}