Python _ssl.SSLError() Examples

The following are 16 code examples of _ssl.SSLError(). 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 _ssl , or try the search function .
Example #1
Source File: ssl.py    From meddle with MIT License 6 votes vote down vote up
def send(self, data, flags=0):
        if self._sslobj:
            if flags != 0:
                raise ValueError(
                    "non-zero flags not allowed in calls to send() on %s" %
                    self.__class__)
            while True:
                try:
                    v = self._sslobj.write(data)
                except SSLError, x:
                    if x.args[0] == SSL_ERROR_WANT_READ:
                        return 0
                    elif x.args[0] == SSL_ERROR_WANT_WRITE:
                        return 0
                    else:
                        raise
                else:
                    return v 
Example #2
Source File: ssl.py    From BinderFilter with MIT License 6 votes vote down vote up
def send(self, data, flags=0):
        if self._sslobj:
            if flags != 0:
                raise ValueError(
                    "non-zero flags not allowed in calls to send() on %s" %
                    self.__class__)
            while True:
                try:
                    v = self._sslobj.write(data)
                except SSLError, x:
                    if x.args[0] == SSL_ERROR_WANT_READ:
                        return 0
                    elif x.args[0] == SSL_ERROR_WANT_WRITE:
                        return 0
                    else:
                        raise
                else:
                    return v 
Example #3
Source File: ssl.py    From pmatic with GNU General Public License v2.0 6 votes vote down vote up
def send(self, data, flags=0):
        if self._sslobj:
            if flags != 0:
                raise ValueError(
                    "non-zero flags not allowed in calls to send() on %s" %
                    self.__class__)
            while True:
                try:
                    v = self._sslobj.write(data)
                except SSLError, x:
                    if x.args[0] == SSL_ERROR_WANT_READ:
                        return 0
                    elif x.args[0] == SSL_ERROR_WANT_WRITE:
                        return 0
                    else:
                        raise
                else:
                    return v 
Example #4
Source File: ssl.py    From RevitBatchProcessor with GNU General Public License v3.0 6 votes vote down vote up
def send(self, data, flags=0):
        if self._sslobj:
            if flags != 0:
                raise ValueError(
                    "non-zero flags not allowed in calls to send() on %s" %
                    self.__class__)
            while True:
                try:
                    v = self._sslobj.write(data)
                except SSLError, x:
                    if x.args[0] == SSL_ERROR_WANT_READ:
                        return 0
                    elif x.args[0] == SSL_ERROR_WANT_WRITE:
                        return 0
                    else:
                        raise
                else:
                    return v 
Example #5
Source File: ssl.py    From canape with GNU General Public License v3.0 6 votes vote down vote up
def send(self, data, flags=0):
        if self._sslobj:
            if flags != 0:
                raise ValueError(
                    "non-zero flags not allowed in calls to send() on %s" %
                    self.__class__)
            while True:
                try:
                    v = self._sslobj.write(data)
                except SSLError, x:
                    if x.args[0] == SSL_ERROR_WANT_READ:
                        return 0
                    elif x.args[0] == SSL_ERROR_WANT_WRITE:
                        return 0
                    else:
                        raise
                else:
                    return v 
Example #6
Source File: ssl.py    From meddle with MIT License 5 votes vote down vote up
def read(self, len=1024):

        """Read up to LEN bytes and return them.
        Return zero-length string on EOF."""

        try:
            return self._sslobj.read(len)
        except SSLError, x:
            if x.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
                return ''
            else:
                raise 
Example #7
Source File: test__ssl.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_SSLError(self):
        self.assertEqual(real_ssl.SSLError.__bases__, (socket.error, )) 
Example #8
Source File: test__ssl.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_SSLType_ssl_neg(self):
        '''
        See comments on test_SSLType_ssl.  Basically this needs to be revisited
        entirely (TODO) after we're more compatible with CPython.
        '''
        s = socket.socket(socket.AF_INET)
        s.connect((SSL_URL, SSL_PORT))

        #--Negative

        #Empty
        self.assertRaises(TypeError, real_ssl.sslwrap)
        self.assertRaises(TypeError, real_ssl.sslwrap, False)

        #None
        self.assertRaises(TypeError, real_ssl.sslwrap, None, False)

        #s, bad keyfile
        #Should throw _ssl.SSLError because both keyfile and certificate weren't specified
        self.assertRaises(real_ssl.SSLError, real_ssl.sslwrap, s._sock, False, "bad keyfile")

        #s, bad certfile
        #Should throw _ssl.SSLError because both keyfile and certificate weren't specified

        #s, bad keyfile, bad certfile
        #Should throw ssl.SSLError
        self.assertRaises(real_ssl.SSLError, real_ssl.sslwrap, s._sock, False, "bad keyfile", "bad certfile")

        #Cleanup
        s.close() 
Example #9
Source File: ssl.py    From BinderFilter with MIT License 5 votes vote down vote up
def read(self, len=1024):

        """Read up to LEN bytes and return them.
        Return zero-length string on EOF."""

        try:
            return self._sslobj.read(len)
        except SSLError, x:
            if x.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
                return ''
            else:
                raise 
Example #10
Source File: ssl.py    From pmatic with GNU General Public License v2.0 5 votes vote down vote up
def read(self, len=1024):

        """Read up to LEN bytes and return them.
        Return zero-length string on EOF."""

        try:
            return self._sslobj.read(len)
        except SSLError, x:
            if x.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
                return ''
            else:
                raise 
Example #11
Source File: detection.py    From WAD with GNU General Public License v3.0 5 votes vote down vote up
def get_content(self, page, url):
        """
        :return: Content if present, None on handled exception
        """
        try:
            content = page.read()
        except (socket.timeout, six.moves.http_client.HTTPException, SSLError) as e:
            logging.info("Exception while reading %s, terminating: %s", url, tools.error_to_str(e))
            return None
        return content 
Example #12
Source File: test__ssl.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def test_SSLError(self):
        self.assertEqual(_ssl.SSLError.__bases__, (socket.error, )) 
Example #13
Source File: test__ssl.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def test_SSLType_ssl_neg(self):
        '''
        See comments on test_SSLType_ssl.  Basically this needs to be revisited
        entirely (TODO) after we're more compatible with CPython.
        '''
        s = socket.socket(socket.AF_INET)
        s.connect((SSL_URL, SSL_PORT))

        #--Negative

        #Empty
        self.assertRaises(TypeError, _ssl.sslwrap)
        self.assertRaises(TypeError, _ssl.sslwrap, False)

        #None
        self.assertRaises(TypeError, _ssl.sslwrap, None, False)

        #s, bad keyfile
        #Should throw _ssl.SSLError because both keyfile and certificate weren't specified

        #s, bad certfile
        #Should throw _ssl.SSLError because both keyfile and certificate weren't specified

        #s, bad keyfile, bad certfile
        #Should throw ssl.SSLError
        self.assertRaises(_ssl.SSLError, _ssl.sslwrap, s, False, "bad keyfile", "bad certfile")

        #Cleanup
        s.close() 
Example #14
Source File: ssl.py    From RevitBatchProcessor with GNU General Public License v3.0 5 votes vote down vote up
def read(self, len=1024):

        """Read up to LEN bytes and return them.
        Return zero-length string on EOF."""

        try:
            return self._sslobj.read(len)
        except SSLError, x:
            if x.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
                return ''
            else:
                raise 
Example #15
Source File: ssl.py    From canape with GNU General Public License v3.0 5 votes vote down vote up
def read(self, len=1024):

        """Read up to LEN bytes and return them.
        Return zero-length string on EOF."""

        try:
            return self._sslobj.read(len)
        except SSLError, x:
            if x.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
                return ''
            else:
                raise 
Example #16
Source File: gsexploreritems.py    From qgis-geoserver-plugin with GNU General Public License v2.0 4 votes vote down vote up
def addGeoServerCatalog(self, explorer):
        dlg = DefineCatalogDialog(self._catalogs)
        dlg.exec_()
        if dlg.ok:
            try:
                QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
                if dlg.authid:
                    cache_time = pluginSetting("AuthCatalogXMLCacheTime")
                    cat = AuthCatalog(dlg.url, dlg.authid, cache_time)
                    self.catalog = cat
                else:
                    cat = BaseCatalog(dlg.url, dlg.username, dlg.password)
                cat.authid = dlg.authid
                v = cat.gsversion()
                try:
                    major = int(v.split(".")[0])
                    minor = int(v.split(".")[1])
                    supported = major > 2 or (major == 2 and minor > 2)
                except:
                    supported = False
                if not supported:
                    QApplication.restoreOverrideCursor()
                    ret = QMessageBox.warning(explorer, "GeoServer catalog definition",
                                    "The specified catalog seems to be running an older\n"
                                    "or unidentified version of GeoServer.\n"
                                    "That might cause unexpected behaviour.\nDo you want to add the catalog anyway?",
                                    QMessageBox.Yes | QMessageBox.No,
                                    QMessageBox.No);
                    if ret == QMessageBox.No:
                        return
                    QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
                geoserverItem = GsCatalogItem(cat, dlg.name)
                self.addChild(geoserverItem)
                geoserverItem.populate()
                self.setExpanded(True)
            except FailedRequestError as e:
                setError("Error connecting to server (See log for more details)", traceback.format_exc())
            except SSLError:
                setWarning("Cannot connect using the provided certificate/key values")
            except Exception as e:
                setError("Could not connect to catalog", traceback.format_exc())
            finally:
                QApplication.restoreOverrideCursor()