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
 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()
Пример #4
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
Пример #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
    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
Пример #11
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
        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
Пример #14
0
 def getContext(self, hostname, port):
     # FIXME: no attempt to verify certificates!
     return ClientContextFactory.getContext(self)
Пример #15
0
 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
 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
Пример #26
0
 def getContext(self):
     self.method = SSL.SSLv23_METHOD
     ctx = ClientContextFactory.getContext(self)
     return ctx
Пример #27
0
    def getContext(self, hostname, port):
        """ Returns a ClientConextFactory used to prepare a
            connection to the Blackberry push service. """

        return ClientContextFactory.getContext(self)
Пример #28
0
 def getContext(self):
     """Get the parent context but disable SSLv3."""
     ctx = ClientContextFactory.getContext(self)
     ctx.set_options(OP_NO_SSLv3)
     return ctx
Пример #29
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
Пример #30
0
 def getContext(self):
     self.method = SSL.SSLv23_METHOD
     ctx = ClientContextFactory.getContext(self)
     return ctx
Пример #31
0
 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