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
示例#2
0
文件: http.py 项目: zhaozw/hall37
 def getContext(self):
     ctx = ClientContextFactory.getContext(self)
     if self.cfile:
         ctx.use_certificate_file(self.cfile)
     if self.kfile:
         ctx.use_privatekey_file(self.kfile)
     return ctx
示例#3
0
class MyWebClientContextFactory(object):

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

    def getContext(self, hostname, port):
        return self._options.getContext()
 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
示例#5
0
 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
示例#6
0
 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
示例#7
0
 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
示例#8
0
文件: sandbox.py 项目: kurhula/vumi-1
    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()
示例#9
0
    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
示例#10
0
        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
    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
        from OpenSSL import SSL


# class CustomContextFactory(ScrapyClientContextFactory):
#     """
#     Custom context factory that allows SSL negotiation.
#     """

#     def __init__(self):
#         # Use SSLv23_METHOD so we can use protocol negotiation
#         self.method = SSL.SSLv23_METHOD
示例#12
0
 def getContext(self, hostname):
     print(hostname)
     return ClientContextFactory.getContext(self)
示例#13
0
 def getContext(self, hostname=None, port=None):
     ctx = ClientContextFactory.getContext(self)
     ctx.set_options(SSL.OP_ALL)
     if hostname:
         ClientTLSOptions(hostname, ctx)
     return ctx
 def getContext(self, hostname, port):
     # FIXME: no attempt to verify certificates!
     return ClientContextFactory.getContext(self)
示例#15
0
文件: proxy_ssl.py 项目: tonky/proxy
 def getContext(self, hostname, port):
     print ">>> getContext", hostname, port
     ctx = ClientContextFactory.getContext(self)
     ctx.set_verify(SSL.VERIFY_NONE, self.verifyHost)
     return ctx
示例#16
0
 def getContext(self, *_):
     return ClientContextFactory.getContext(self)
示例#17
0
 def getContext(self, hostname=None, port=None):
     ctx = ClientContextFactory.getContext(self)
     # Enable all workarounds to SSL bugs as documented by
     # https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_options.html
     ctx.set_options(SSL.OP_ALL)
     return ctx
示例#18
0
 def getContext(self):
     """Get the parent context but disable SSLv3."""
     ctx = ClientContextFactory.getContext(self)
     ctx.set_options(OP_NO_SSLv3)
     return ctx
示例#19
0
	def getContext(self, hostname, port):
		return ClientContextFactory.getContext(self)
示例#20
0
 def getContext(self, host=None, port=None):
     return ClientContextFactory.getContext(self)
示例#21
0
 def getContext(self, hostname, port):
     """Provide Twisted Web client context."""
     return ClientContextFactory.getContext(self)
示例#22
0
 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
示例#23
0
 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
示例#24
0
文件: utils.py 项目: geostarling/duct
 def getContext(self, *_a):
     return ClientContextFactory.getContext(self)
示例#25
0
 def getContext(self, hostname=None, port=None):
     ctx = ClientContextFactory.getContext(self)
     ctx.set_options(SSL.OP_ALL)
     if hostname and ClientTLSOptions is not None:  # workaround for TLS SNI
         ClientTLSOptions(hostname, ctx)
     return ctx
 def getContext(self):
     self.method = SSL.SSLv23_METHOD
     ctx = ClientContextFactory.getContext(self)
     return ctx
示例#27
0
文件: gcm.py 项目: tim-jackson/pushpy
    def getContext(self, hostname, port):
        """ Returns a ClientConextFactory used to prepare a
            connection to the Blackberry push service. """

        return ClientContextFactory.getContext(self)
示例#28
0
文件: mail.py 项目: ygl-rg/cyclone3
 def getContext(self):
     """Get the parent context but disable SSLv3."""
     ctx = ClientContextFactory.getContext(self)
     ctx.set_options(OP_NO_SSLv3)
     return ctx
示例#29
0
文件: webclient.py 项目: ygkee/scrapy
 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
示例#30
0
 def getContext(self):
     self.method = SSL.SSLv23_METHOD
     ctx = ClientContextFactory.getContext(self)
     return ctx
示例#31
0
文件: pybench.py 项目: Clever/flood
 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)
示例#32
0
 def getContext(self, hostname, port):
     return ClientContextFactory.getContext(self)
示例#33
0
 def getContext(self, hostname=None, port=None):
     ctx = ClientContextFactory.getContext(self)
     # Enable all workarounds to SSL bugs as documented by
     # https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set_options.html
     ctx.set_options(SSL.OP_ALL)
     return ctx