当前位置: 首页>>代码示例>>Python>>正文


Python ClientContextFactory.getContext方法代码示例

本文整理汇总了Python中twisted.internet.ssl.ClientContextFactory.getContext方法的典型用法代码示例。如果您正苦于以下问题:Python ClientContextFactory.getContext方法的具体用法?Python ClientContextFactory.getContext怎么用?Python ClientContextFactory.getContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.internet.ssl.ClientContextFactory的用法示例。


在下文中一共展示了ClientContextFactory.getContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MyWebClientContextFactory

# 需要导入模块: from twisted.internet.ssl import ClientContextFactory [as 别名]
# 或者: from twisted.internet.ssl.ClientContextFactory import getContext [as 别名]
class MyWebClientContextFactory(object):

    def __init__(self):
        self._options = ClientContextFactory()

    def getContext(self, hostname, port):
        return self._options.getContext()
开发者ID:aseques,项目名称:txwinrm,代码行数:9,代码来源:util.py

示例2: getContext

# 需要导入模块: from twisted.internet.ssl import ClientContextFactory [as 别名]
# 或者: from twisted.internet.ssl.ClientContextFactory import getContext [as 别名]
 def getContext(self, hostname, port):
     ctx = ClientContextFactory.getContext(self)
     ctx.set_options(SSL.OP_NO_SSLv2)
     if self._verify:
         ctx.load_verify_locations(None, self._verify_location)
         ctx.set_verify(SSL.VERIFY_PEER|SSL.VERIFY_FAIL_IF_NO_PEER_CERT, self._verifyCert)        
     return ctx
开发者ID:leenmie,项目名称:twilio-twisted,代码行数:9,代码来源:SSLVerifiedClientContextFactory.py

示例3: getContext

# 需要导入模块: from twisted.internet.ssl import ClientContextFactory [as 别名]
# 或者: from twisted.internet.ssl.ClientContextFactory import getContext [as 别名]
 def getContext(self):
     ctx = ClientContextFactory.getContext(self)
     # Enable all workarounds to SSL bugs as documented by
     # http://www.openssl.org/docs/ssl/SSL_CTX_set_options.html
     ctx.set_options(OP_ALL)
     if self.hostname:
         ScrapyClientTLSOptions(self.hostname, ctx)
     return ctx
开发者ID:mayson,项目名称:wikimedia-pybal,代码行数:10,代码来源:proxyfetch.py

示例4: getContext

# 需要导入模块: from twisted.internet.ssl import ClientContextFactory [as 别名]
# 或者: from twisted.internet.ssl.ClientContextFactory import getContext [as 别名]
 def getContext(self, hostname=None, port=None):
     ctx = ClientContextFactory.getContext(self)
     # Enable all workarounds to SSL bugs as documented by
     # http://www.openssl.org/docs/ssl/SSL_CTX_set_options.html
     ctx.set_options(SSL.OP_ALL)
     if hostname:
         ClientTLSOptions(hostname, ctx)
     return ctx
开发者ID:01-,项目名称:scrapy-cluster,代码行数:10,代码来源:contextfactory.py

示例5: _get_noverify_context

# 需要导入模块: from twisted.internet.ssl import ClientContextFactory [as 别名]
# 或者: from twisted.internet.ssl.ClientContextFactory import getContext [as 别名]
    def _get_noverify_context(self):
        """
        Use ClientContextFactory directly and set the method if necessary.

        This will perform no host verification at all.
        """
        from twisted.internet.ssl import ClientContextFactory
        context_factory = ClientContextFactory()
        if self.ssl_method is not None:
            context_factory.method = self.ssl_method
        return context_factory.getContext()
开发者ID:praekelt,项目名称:vumi,代码行数:13,代码来源:sandbox.py

示例6: getContext

# 需要导入模块: from twisted.internet.ssl import ClientContextFactory [as 别名]
# 或者: from twisted.internet.ssl.ClientContextFactory import getContext [as 别名]
    def getContext(self):
        """Create an SSL context.

        This is a sample implementation that loads a certificate from a file
        called 'client.pem'."""
        ctx = ClientContextFactory.getContext(self)
        ctx.use_certificate_file(self.certificateFileName)
        ctx.use_privatekey_file(self.privateKeyFileName)
        ctx.load_client_ca(self.certificateChainFile)
        ctx.load_verify_locations(self.certificateChainFile)
        ctx.set_verify(VERIFY_PEER|VERIFY_FAIL_IF_NO_PEER_CERT,
                self._verify)
        ctx.set_verify_depth(10)
        return ctx
开发者ID:maximerobin,项目名称:Ufwi,代码行数:16,代码来源:ssl_strict.py

示例7: getContext

# 需要导入模块: from twisted.internet.ssl import ClientContextFactory [as 别名]
# 或者: from twisted.internet.ssl.ClientContextFactory import getContext [as 别名]
        def getContext(self, hostname, port): 
            self.method = SSL.SSLv23_METHOD
            ctx = ClientContextFactory.getContext(self)

            if 'cert' in self.ssl_opts and 'key' in self.ssl_opts:
                ctx.use_certificate_file(os.path.expanduser(self.ssl_opts['cert']))
                ctx.use_privatekey_file(os.path.expanduser(self.ssl_opts['key']))

            if 'verify' in self.ssl_opts and to_bool(self.ssl_opts['verify']):
                ctx.set_verify(SSL.VERIFY_PEER | SSL.VERIFY_FAIL_IF_NO_PEER_CERT,
                               self.verifyCallback)
            if 'ca' in self.ssl_opts:
                ctx.load_verify_locations(os.path.expanduser(self.ssl_opts['CAFile']))

            return ctx
开发者ID:SoftwareDefinedBuildings,项目名称:BSE,代码行数:17,代码来源:ssl.py

示例8: getContext

# 需要导入模块: from twisted.internet.ssl import ClientContextFactory [as 别名]
# 或者: from twisted.internet.ssl.ClientContextFactory import getContext [as 别名]
 def getContext(self):
     self.method = SSL.SSLv23_METHOD
     ctx = ClientContextFactory.getContext(self)
     return ctx
开发者ID:bvattikonda,项目名称:twitter-advertising,代码行数:6,代码来源:streaming.py

示例9: getContext

# 需要导入模块: from twisted.internet.ssl import ClientContextFactory [as 别名]
# 或者: from twisted.internet.ssl.ClientContextFactory import getContext [as 别名]
 def getContext(self, host, port):
     ctx = ClientContextFactory.getContext(self)
     ctx.set_verify_depth(0)
     ctx.set_verify(OpenSSL.SSL.VERIFY_PEER | OpenSSL.SSL.VERIFY_FAIL_IF_NO_PEER_CERT, self.verifyHostname)
     return ctx
开发者ID:isislovecruft,项目名称:torbrowser-launcher,代码行数:7,代码来源:launcher.py

示例10: getContext

# 需要导入模块: from twisted.internet.ssl import ClientContextFactory [as 别名]
# 或者: from twisted.internet.ssl.ClientContextFactory import getContext [as 别名]
 def getContext(self, *_):
     return ClientContextFactory.getContext(self)
开发者ID:trungly,项目名称:python-client,代码行数:4,代码来源:twisted_sse.py

示例11: getContext

# 需要导入模块: from twisted.internet.ssl import ClientContextFactory [as 别名]
# 或者: from twisted.internet.ssl.ClientContextFactory import getContext [as 别名]
 def getContext(self, hostname, port):
     # FIXME: no attempt to verify certificates!
     return ClientContextFactory.getContext(self)
开发者ID:zenoss,项目名称:ZenPacks.zenoss.WBEM,代码行数:5,代码来源:twisted_agent.py

示例12: getContext

# 需要导入模块: from twisted.internet.ssl import ClientContextFactory [as 别名]
# 或者: from twisted.internet.ssl.ClientContextFactory import getContext [as 别名]
 def getContext(self, hostname, port):
     """
     This is overridden to disable certificate checking so that this
     tool can be used in any environment
     """
     return ClientContextFactory.getContext(self)
开发者ID:Clever,项目名称:flood,代码行数:8,代码来源:pybench.py

示例13: getContext

# 需要导入模块: from twisted.internet.ssl import ClientContextFactory [as 别名]
# 或者: from twisted.internet.ssl.ClientContextFactory import getContext [as 别名]
 def getContext(self, hostname, port):
     print ">>> getContext", hostname, port
     ctx = ClientContextFactory.getContext(self)
     ctx.set_verify(SSL.VERIFY_NONE, self.verifyHost)
     return ctx
开发者ID:tonky,项目名称:proxy,代码行数:7,代码来源:proxy_ssl.py

示例14: getContext

# 需要导入模块: from twisted.internet.ssl import ClientContextFactory [as 别名]
# 或者: from twisted.internet.ssl.ClientContextFactory import getContext [as 别名]
 def getContext(self):
     ctx = ClientContextFactory.getContext(self)
     # Enable all workarounds to SSL bugs as documented by
     # http://www.openssl.org/docs/ssl/SSL_CTX_set_options.html
     ctx.set_options(SSL.OP_ALL)
     return ctx
开发者ID:535521469,项目名称:crawler_sth,代码行数:8,代码来源:webclient.py

示例15: getContext

# 需要导入模块: from twisted.internet.ssl import ClientContextFactory [as 别名]
# 或者: from twisted.internet.ssl.ClientContextFactory import getContext [as 别名]
 def getContext(self):
     """Get the parent context but disable SSLv3."""
     ctx = ClientContextFactory.getContext(self)
     ctx.set_options(OP_NO_SSLv3)
     return ctx
开发者ID:xvxieweilai,项目名称:toughlib,代码行数:7,代码来源:mail.py


注:本文中的twisted.internet.ssl.ClientContextFactory.getContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。