public ProposalResponse SendProposal(SignedProposal proposal) { if (shutdown) { throw new PeerException("Shutdown"); } return(ecl.ProcessProposal(proposal)); }
public void SelfSignedTLSCertTest() { bool handshakeOccured = false; Server sv = new Server(); TLSCertificateKeyPair serverCert = TLSCertificateKeyPair.CreateServerCert("localhost"); TLSCertificateKeyPair clientCert = TLSCertificateKeyPair.CreateClientCert(); KeyCertificatePair pair = new KeyCertificatePair(serverCert.CertPEMBytes.ToUTF8String(), serverCert.KeyPEMBytes.ToUTF8String()); ServerCredentials credentials = new SslServerCredentials(new[] { pair }, clientCert.CertPEMBytes.ToUTF8String(), true); sv.Ports.Add(new ServerPort("localhost", 0, credentials)); sv.Services.Add(Endorser.BindService(new MockEndorser()).Intercept(new MultalTLSInterceptor(clientCert.CertPEMBytes, (b) => handshakeOccured = b))); sv.Start(); int port = sv.Ports.First().BoundPort; ChannelCredentials cred = new SslCredentials(serverCert.CertPEMBytes.ToUTF8String(), new KeyCertificatePair(clientCert.CertPEMBytes.ToUTF8String(), clientCert.KeyPEMBytes.ToUTF8String())); Channel chan = new Channel("localhost", port, cred); SignedProposal prop = new SignedProposal(); Endorser.EndorserClient cl = new Endorser.EndorserClient(chan); cl.ProcessProposal(prop); Assert.IsTrue(handshakeOccured, "Handshake didn't occur"); chan.ShutdownAsync().RunAndUnwrap(); sv.ShutdownAsync().RunAndUnwrap(); }