def loopbackTLSConnection(trustRoot, privateKeyFile, chainedCertFile=None):
 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)

def loopbackTLSConnection ( trustRoot , privateKeyFile , chainedCertFile = None ) : class ContextFactory ( object , ) : def getContext ( self ) : 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 )
create a loopback tls connection with the given trust and keys .