コード例 #1
0
ファイル: test_client.py プロジェクト: mithrandi/txacme
 def _create_responder(self):
     action = start_action(action_type=u'integration:create_responder')
     with action.context():
         responder = TLSSNI01Responder()
         host_map = responder.wrap_host_map({})
         site = Site(Resource())
         endpoint = TLSEndpoint(
             endpoint=serverFromString(reactor, self.ENDPOINT),
             contextFactory=SNIMap(host_map))
         return (
             DeferredContext(endpoint.listen(site))
             .addCallback(lambda port: self.addCleanup(port.stopListening))
             .addCallback(lambda _: responder)
             .addActionFinish())
コード例 #2
0
def sni_endpoint():
    """
    Builds a TxSNI TLSEndpoint populated with the default certificates. These
    are built from cert_builder.py, and have the following certs in the SNI
    map:

    - DEFAULT.pem, which contains a SAN for 'localhost'.
    - http2bin.org.pem, which contains a SAN for 'http2bin.org'
    """
    base_endpoint = endpoints.TCP4ServerEndpoint(
        reactor=reactor,
        port=0,
        interface='127.0.0.1',
    )
    path = FilePath(CERT_DIR)
    mapping = SNIMap(HostDirectoryMap(path))
    wrapper_endpoint = TLSEndpoint(base_endpoint, mapping)
    return wrapper_endpoint