human
Complete this python program:
def loopbackTLSConnection(trustRoot, privateKeyFile, chainedCertFile=None):
assistant
#Here is the Python program you requested.

    """Create a loopback TLS connection with the given trust and keys.
    @param trustRoot: the C{trustRoot} argument for the client connection\s
    context.
    @type trustRoot: L{sslverify.IOpenSSLTrustRoot}
    @param privateKeyFile: The name of the file containing the private key.
    @type privateKeyFile: L{str} (native string; file name)
    @param chainedCertFile: The name of the chained certificate file.
    @type chainedCertFile: L{str} (native string; file name)
    @return: 3-tuple of server-protocol, client-protocol, and L{IOPump}
    @rtype: L{tuple}
    """
    class ContextFactory(object, ):
        def getContext(self):
            '\n                                                Create    a    context    for    the    server    side    of    the    connection.\n\n                                                @return:    an    SSL    context    using    a    certificate    and    key.\n                                                @rtype:    C{OpenSSL.SSL.Context}\n                                                '
            ctx = SSL.Context(SSL.TLSv1_METHOD)
            if (chainedCertFile is not None):
                ctx.use_certificate_chain_file(chainedCertFile)
            ctx.use_privatekey_file(privateKeyFile)
            ctx.check_privatekey()
            return ctx
    serverOpts = ContextFactory()
    clientOpts = sslverify.OpenSSLCertificateOptions(trustRoot=trustRoot)
    return _loopbackTLSConnection(serverOpts, clientOpts)