'Using real, live TLS, actually negotiate a connection.
This also looks at the \'peerCertificate\' attribute\'s correctness, since
that\'s actually loaded using OpenSSL calls, but the main purpose is to
make sure that we didn\'t miss anything obvious in iosim about TLS
negotiations.'

def test_liveFireCustomTLS(self):

    cert = tempcert
    self.svr.verifyFactory = (lambda : [cert])
    self.svr.certFactory = (lambda : cert)
    def secured(rslt):
        x = cert.digest()
        def pinged(rslt2):
            self.assertEqual(x, self.cli.hostCertificate.digest())
            self.assertEqual(x, self.cli.peerCertificate.digest())
            self.assertEqual(x, self.svr.hostCertificate.digest())
            self.assertEqual(x, self.svr.peerCertificate.digest())
        return self.cli.callRemote(SecuredPing).addCallback(pinged)
    return self.cli.callRemote(amp.StartTLS, tls_localCertificate=cert, tls_verifyAuthorities=[cert]).addCallback(secured)
