Python twisted.internet.interfaces.IReactorSSL() Examples

The following are 23 code examples of twisted.internet.interfaces.IReactorSSL(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module twisted.internet.interfaces , or try the search function .
Example #1
Source File: test_ssl.py    From python-for-android with Apache License 2.0 6 votes vote down vote up
def getHandleErrorCode(self):
        """
        Return the argument L{SSL.Error} will be constructed with for this
        case.  This is basically just a random OpenSSL implementation detail.
        It would be better if this test worked in a way which did not require
        this.
        """
        # Windows 2000 SP 4 and Windows XP SP 2 give back WSAENOTSOCK for
        # SSL.Connection.write for some reason.  The twisted.protocols.tls
        # implementation of IReactorSSL doesn't suffer from this imprecation,
        # though, since it is isolated from the Windows I/O layer (I suppose?).

        # If test_properlyCloseFiles waited for the SSL handshake to complete
        # and performed an orderly shutdown, then this would probably be a
        # little less weird: writing to a shutdown SSL connection has a more
        # well-defined failure mode (or at least it should).
        name = fullyQualifiedName(getClass(reactor))
        if platform.getType() == 'win32' and name != self._iocp:
            return errno.WSAENOTSOCK
        # This is terribly implementation-specific.
        return [('SSL routines', 'SSL_write', 'protocol is shutdown')] 
Example #2
Source File: reactor.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def listenSSL(self, port, factory, contextFactory, backlog=50, interface=''):
            """
            @see: twisted.internet.interfaces.IReactorSSL.listenSSL
            """
            return self.listenTCP(
                port,
                TLSMemoryBIOFactory(contextFactory, False, factory),
                backlog, interface) 
Example #3
Source File: posixbase.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def listenSSL(self, port, factory, contextFactory, backlog=50, interface=''):
        """@see: twisted.internet.interfaces.IReactorSSL.listenSSL
        """
        assert sslEnabled, "SSL support is not present"
        p = ssl.Port(port, factory, contextFactory, backlog, interface, self)
        p.startListening()
        return p

    # IReactorArbitrary 
Example #4
Source File: posixbase.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def connectSSL(self, host, port, factory, contextFactory, timeout=30, bindAddress=None):
        """@see: twisted.internet.interfaces.IReactorSSL.connectSSL
        """
        assert sslEnabled, "SSL support is not present"
        c = ssl.Connector(host, port, factory, contextFactory, timeout, bindAddress, self)
        c.connect()
        return c 
Example #5
Source File: posixbase.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def connectTCP(self, host, port, factory, timeout=30, bindAddress=None):
        """@see: twisted.internet.interfaces.IReactorTCP.connectTCP
        """
        c = tcp.Connector(host, port, factory, timeout, bindAddress, self)
        c.connect()
        return c

    # IReactorSSL (sometimes, not implemented) 
Example #6
Source File: test_ssl.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def connectClient(self, address, portNumber, clientCreator):
        """
        Create an SSL client using L{IReactorSSL.connectSSL}.
        """
        contextFactory = ssl.CertificateOptions()
        return clientCreator.connectSSL(address, portNumber, contextFactory) 
Example #7
Source File: test_ssl.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def createServer(self, address, portNumber, factory):
        """
        Create an SSL server with a certificate using L{IReactorSSL.listenSSL}.
        """
        cert = ssl.PrivateCertificate.loadPEM(file(certPath).read())
        contextFactory = cert.options()
        return reactor.listenSSL(
            portNumber, factory, contextFactory, interface=address) 
Example #8
Source File: posixbase.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def listenSSL(self, port, factory, contextFactory, backlog=50, interface=''):
        """@see: twisted.internet.interfaces.IReactorSSL.listenSSL
        """
        assert sslEnabled, "SSL support is not present"
        p = ssl.Port(port, factory, contextFactory, backlog, interface, self)
        p.startListening()
        return p


    # IReactorArbitrary 
Example #9
Source File: posixbase.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def connectTCP(self, host, port, factory, timeout=30, bindAddress=None):
        """@see: twisted.internet.interfaces.IReactorTCP.connectTCP
        """
        c = tcp.Connector(host, port, factory, timeout, bindAddress, self)
        c.connect()
        return c

    # IReactorSSL (sometimes, not implemented) 
Example #10
Source File: reactor.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def connectSSL(self, host, port, factory, contextFactory, timeout=30, bindAddress=None):
            """
            Non-implementation of L{IReactorSSL.connectSSL}.  Some dependency
            is not satisfied.  This implementation always raises
            L{NotImplementedError}.
            """
            raise NotImplementedError(
                "pyOpenSSL 0.10 or newer is required for SSL support in "
                "iocpreactor. It is missing, so the reactor does not support "
                "SSL APIs.") 
Example #11
Source File: reactor.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def listenSSL(self, port, factory, contextFactory, backlog=50, interface=''):
            """
            Non-implementation of L{IReactorSSL.listenSSL}.  Some dependency
            is not satisfied.  This implementation always raises
            L{NotImplementedError}.
            """
            raise NotImplementedError(
                "pyOpenSSL 0.10 or newer is required for SSL support in "
                "iocpreactor. It is missing, so the reactor does not support "
                "SSL APIs.") 
Example #12
Source File: reactor.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def connectSSL(self, host, port, factory, contextFactory, timeout=30, bindAddress=None):
            """
            @see: twisted.internet.interfaces.IReactorSSL.connectSSL
            """
            return self.connectTCP(
                host, port,
                TLSMemoryBIOFactory(contextFactory, True, factory),
                timeout, bindAddress) 
Example #13
Source File: reactor.py    From Safejumper-for-Desktop with GNU General Public License v2.0 5 votes vote down vote up
def listenSSL(self, port, factory, contextFactory, backlog=50, interface=''):
            """
            @see: twisted.internet.interfaces.IReactorSSL.listenSSL
            """
            port = self.listenTCP(
                port,
                TLSMemoryBIOFactory(contextFactory, False, factory),
                backlog, interface)
            port._type = 'TLS'
            return port 
Example #14
Source File: test_ssl.py    From learn_python3_spider with MIT License 5 votes vote down vote up
def createServer(self, address, portNumber, factory):
        """
        Create an SSL server with a certificate using L{IReactorSSL.listenSSL}.
        """
        cert = ssl.PrivateCertificate.loadPEM(FilePath(certPath).getContent())
        contextFactory = cert.options()
        return reactor.listenSSL(
            portNumber, factory, contextFactory, interface=address) 
Example #15
Source File: reactor.py    From learn_python3_spider with MIT License 5 votes vote down vote up
def connectSSL(self, host, port, factory, contextFactory, timeout=30, bindAddress=None):
            """
            Non-implementation of L{IReactorSSL.connectSSL}.  Some dependency
            is not satisfied.  This implementation always raises
            L{NotImplementedError}.
            """
            raise NotImplementedError(
                "pyOpenSSL 0.10 or newer is required for SSL support in "
                "iocpreactor. It is missing, so the reactor does not support "
                "SSL APIs.") 
Example #16
Source File: reactor.py    From learn_python3_spider with MIT License 5 votes vote down vote up
def listenSSL(self, port, factory, contextFactory, backlog=50, interface=''):
            """
            Non-implementation of L{IReactorSSL.listenSSL}.  Some dependency
            is not satisfied.  This implementation always raises
            L{NotImplementedError}.
            """
            raise NotImplementedError(
                "pyOpenSSL 0.10 or newer is required for SSL support in "
                "iocpreactor. It is missing, so the reactor does not support "
                "SSL APIs.") 
Example #17
Source File: reactor.py    From learn_python3_spider with MIT License 5 votes vote down vote up
def connectSSL(self, host, port, factory, contextFactory, timeout=30, bindAddress=None):
            """
            @see: twisted.internet.interfaces.IReactorSSL.connectSSL
            """
            return self.connectTCP(
                host, port,
                TLSMemoryBIOFactory(contextFactory, True, factory),
                timeout, bindAddress) 
Example #18
Source File: reactor.py    From learn_python3_spider with MIT License 5 votes vote down vote up
def listenSSL(self, port, factory, contextFactory, backlog=50, interface=''):
            """
            @see: twisted.internet.interfaces.IReactorSSL.listenSSL
            """
            port = self.listenTCP(
                port,
                TLSMemoryBIOFactory(contextFactory, False, factory),
                backlog, interface)
            port._type = 'TLS'
            return port 
Example #19
Source File: test_ssl.py    From Safejumper-for-Desktop with GNU General Public License v2.0 5 votes vote down vote up
def getHandleErrorCode(self):
        """
        Return the argument L{OpenSSL.SSL.Error} will be constructed with for
        this case. This is basically just a random OpenSSL implementation
        detail. It would be better if this test worked in a way which did not
        require this.
        """
        # Windows 2000 SP 4 and Windows XP SP 2 give back WSAENOTSOCK for
        # SSL.Connection.write for some reason.  The twisted.protocols.tls
        # implementation of IReactorSSL doesn't suffer from this imprecation,
        # though, since it is isolated from the Windows I/O layer (I suppose?).

        # If test_properlyCloseFiles waited for the SSL handshake to complete
        # and performed an orderly shutdown, then this would probably be a
        # little less weird: writing to a shutdown SSL connection has a more
        # well-defined failure mode (or at least it should).

        # So figure out if twisted.protocols.tls is in use.  If it can be
        # imported, it should be.
        if requireModule('twisted.protocols.tls') is None:
            # It isn't available, so we expect WSAENOTSOCK if we're on Windows.
            if platform.getType() == 'win32':
                return errno.WSAENOTSOCK

        # Otherwise, we expect an error about how we tried to write to a
        # shutdown connection.  This is terribly implementation-specific.
        return [('SSL routines', 'SSL_write', 'protocol is shutdown')] 
Example #20
Source File: test_ssl.py    From Safejumper-for-Desktop with GNU General Public License v2.0 5 votes vote down vote up
def createServer(self, address, portNumber, factory):
        """
        Create an SSL server with a certificate using L{IReactorSSL.listenSSL}.
        """
        cert = ssl.PrivateCertificate.loadPEM(FilePath(certPath).getContent())
        contextFactory = cert.options()
        return reactor.listenSSL(
            portNumber, factory, contextFactory, interface=address) 
Example #21
Source File: reactor.py    From Safejumper-for-Desktop with GNU General Public License v2.0 5 votes vote down vote up
def connectSSL(self, host, port, factory, contextFactory, timeout=30, bindAddress=None):
            """
            Non-implementation of L{IReactorSSL.connectSSL}.  Some dependency
            is not satisfied.  This implementation always raises
            L{NotImplementedError}.
            """
            raise NotImplementedError(
                "pyOpenSSL 0.10 or newer is required for SSL support in "
                "iocpreactor. It is missing, so the reactor does not support "
                "SSL APIs.") 
Example #22
Source File: reactor.py    From Safejumper-for-Desktop with GNU General Public License v2.0 5 votes vote down vote up
def listenSSL(self, port, factory, contextFactory, backlog=50, interface=''):
            """
            Non-implementation of L{IReactorSSL.listenSSL}.  Some dependency
            is not satisfied.  This implementation always raises
            L{NotImplementedError}.
            """
            raise NotImplementedError(
                "pyOpenSSL 0.10 or newer is required for SSL support in "
                "iocpreactor. It is missing, so the reactor does not support "
                "SSL APIs.") 
Example #23
Source File: reactor.py    From Safejumper-for-Desktop with GNU General Public License v2.0 5 votes vote down vote up
def connectSSL(self, host, port, factory, contextFactory, timeout=30, bindAddress=None):
            """
            @see: twisted.internet.interfaces.IReactorSSL.connectSSL
            """
            return self.connectTCP(
                host, port,
                TLSMemoryBIOFactory(contextFactory, True, factory),
                timeout, bindAddress)