'Check that anonymous connections are refused when certificates are
required on the server.'

def test_refusedAnonymousClientConnection(self):

    onServerLost = defer.Deferred()
    onClientLost = defer.Deferred()
    self.loopback(sslverify.OpenSSLCertificateOptions(privateKey=self.sKey, certificate=self.sCert, verify=True, caCerts=[self.sCert], requireCertificate=True), sslverify.OpenSSLCertificateOptions(requireCertificate=False), onServerLost=onServerLost, onClientLost=onClientLost)
    d = defer.DeferredList([onClientLost, onServerLost], consumeErrors=True)
    def afterLost(result):
        ((cSuccess, cResult), (sSuccess, sResult)) = result
        self.assertFalse(cSuccess)
        self.assertFalse(sSuccess)
        self.assertIsInstance(cResult.value, (SSL.Error, ConnectionLost))
        self.assertIsInstance(sResult.value, SSL.Error)
    return d.addCallback(afterLost)
