--- a/eric6/E5Network/E5SslErrorHandler.py Tue Apr 27 17:42:00 2021 +0200 +++ b/eric6/E5Network/E5SslErrorHandler.py Wed Apr 28 19:42:28 2021 +0200 @@ -7,8 +7,9 @@ Module implementing a SSL error handler. """ +import contextlib +import enum import platform -import contextlib from PyQt5.QtCore import QObject, QByteArray from PyQt5.QtNetwork import ( @@ -22,6 +23,15 @@ import Globals +class E5SslErrorState(enum.Enum): + """ + Class defining the SSL error handling states. + """ + NOT_IGNORED = 0 + SYSTEM_IGNORED = 1 + USER_IGNORED = 2 + + class E5SslErrorHandler(QObject): """ Class implementing a handler for SSL errors. @@ -29,10 +39,6 @@ It also initializes the default SSL configuration with certificates permanently accepted by the user already. """ - NotIgnored = 0 - SystemIgnored = 1 - UserIgnored = 2 - def __init__(self, parent=None): """ Constructor @@ -105,12 +111,15 @@ """ Public method to handle SSL errors. - @param errors list of SSL errors (list of QSslError) - @param server name of the server (string) - @param port value of the port (integer) - @return tuple indicating to ignore the SSL errors (one of NotIgnored, - SystemIgnored or UserIgnored) and indicating a change of the - default SSL configuration (boolean) + @param errors list of SSL errors + @type list of QSslError + @param server name of the server + @type str + @param port value of the port + @type int + @return tuple indicating to ignore the SSL errors and indicating a + change of the default SSL configuration + @rtype tuple of (E5SslErrorState, bool) """ caMerge = {} certificateDict = Globals.toDict( @@ -135,7 +144,7 @@ if cert not in caNew: caNew.append(cert) if not errorStrings: - return E5SslErrorHandler.SystemIgnored, False + return E5SslErrorState.SYSTEM_IGNORED, False errorString = '.</li><li>'.join(errorStrings) ret = E5MessageBox.yesNo( @@ -192,10 +201,10 @@ "Ssl/CaCertificatesDict", certificateDict) - return E5SslErrorHandler.UserIgnored, caRet + return E5SslErrorState.USER_IGNORED, caRet else: - return E5SslErrorHandler.NotIgnored, False + return E5SslErrorState.NOT_IGNORED, False def __certToString(self, cert): """