当前位置: 首页>>代码示例>>Python>>正文


Python QtNetwork.QSslSocket类代码示例

本文整理汇总了Python中PyQt5.QtNetwork.QSslSocket的典型用法代码示例。如果您正苦于以下问题:Python QSslSocket类的具体用法?Python QSslSocket怎么用?Python QSslSocket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QSslSocket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init

def init():
    """Disable insecure SSL ciphers on old Qt versions."""
    if not qtutils.version_check("5.3.0"):
        # Disable weak SSL ciphers.
        # See https://codereview.qt-project.org/#/c/75943/
        good_ciphers = [c for c in QSslSocket.supportedCiphers() if c.usedBits() >= 128]
        QSslSocket.setDefaultCiphers(good_ciphers)
开发者ID:xu-fengfeng,项目名称:qutebrowser,代码行数:7,代码来源:networkmanager.py

示例2: version

def version():
    """Return a string with various version informations."""
    lines = ["qutebrowser v{}".format(qutebrowser.__version__)]
    gitver = _git_str()
    if gitver is not None:
        lines.append("Git commit: {}".format(gitver))
    lines += [
        '',
        '{}: {}'.format(platform.python_implementation(),
                        platform.python_version()),
        'Qt: {}, runtime: {}'.format(QT_VERSION_STR, qVersion()),
        'PyQt: {}'.format(PYQT_VERSION_STR),
    ]
    lines += _module_versions()

    if QSslSocket is not None and QSslSocket.supportsSsl():
        ssl_version = QSslSocket.sslLibraryVersionString()
    else:
        ssl_version = 'unavailable'
    lines += [
        'Webkit: {}'.format(qWebKitVersion()),
        'Harfbuzz: {}'.format(os.environ.get('QT_HARFBUZZ', 'system')),
        'SSL: {}'.format(ssl_version),
        '',
        'Frozen: {}'.format(hasattr(sys, 'frozen')),
        'Platform: {}, {}'.format(platform.platform(),
                                  platform.architecture()[0]),
    ]
    lines += _os_info()
    return '\n'.join(lines)
开发者ID:tharugrim,项目名称:qutebrowser,代码行数:30,代码来源:version.py

示例3: init

def init():
    """Disable insecure SSL ciphers on old Qt versions."""
    default_ciphers = QSslSocket.defaultCiphers()
    log.init.debug("Default Qt ciphers: {}".format(
        ', '.join(c.name() for c in default_ciphers)))

    good_ciphers = []
    bad_ciphers = []
    for cipher in default_ciphers:
        if _is_secure_cipher(cipher):
            good_ciphers.append(cipher)
        else:
            bad_ciphers.append(cipher)

    log.init.debug("Disabling bad ciphers: {}".format(
        ', '.join(c.name() for c in bad_ciphers)))
    QSslSocket.setDefaultCiphers(good_ciphers)
开发者ID:The-Compiler,项目名称:qutebrowser,代码行数:17,代码来源:networkmanager.py

示例4: version

def version():
    """Return a string with various version informations."""
    lines = ["qutebrowser v{}".format(qutebrowser.__version__)]
    gitver = _git_str()
    if gitver is not None:
        lines.append("Git commit: {}".format(gitver))

    if qVersion() != QT_VERSION_STR:
        qt_version = 'Qt: {} (compiled {})'.format(qVersion(), QT_VERSION_STR)
    else:
        qt_version = 'Qt: {}'.format(qVersion())

    lines += [
        '',
        '{}: {}'.format(platform.python_implementation(),
                        platform.python_version()),
        qt_version,
        'PyQt: {}'.format(PYQT_VERSION_STR),
        '',
    ]

    lines += _module_versions()

    lines += ['pdf.js: {}'.format(_pdfjs_version())]

    if qWebKitVersion is None:
        lines.append('Webkit: no')
    else:
        lines.append('Webkit: {}'.format(qWebKitVersion()))

    lines += [
        'SSL: {}'.format(QSslSocket.sslLibraryVersionString()),
        '',
    ]

    qapp = QApplication.instance()
    if qapp:
        style = qapp.style()
        lines.append('Style: {}'.format(style.metaObject().className()))

    importpath = os.path.dirname(os.path.abspath(qutebrowser.__file__))

    lines += [
        'Platform: {}, {}'.format(platform.platform(),
                                  platform.architecture()[0]),
        'Frozen: {}'.format(hasattr(sys, 'frozen')),
        "Imported from {}".format(importpath),
    ]
    lines += _os_info()

    lines += [
        '',
        'Paths:',
    ]
    for name, path in _path_info().items():
        lines += ['{}: {}'.format(name, path)]

    return '\n'.join(lines)
开发者ID:NoctuaNivalis,项目名称:qutebrowser,代码行数:58,代码来源:version.py

示例5: initSSL

def initSSL():
    """
    Function to initialize some global SSL stuff.
    """
    blacklist = [
        "SRP-AES-256-CBC-SHA",          # open to MitM
        "SRP-AES-128-CBC-SHA",          # open to MitM
    ]
    
    try:
        from PyQt5.QtNetwork import QSslSocket
    except ImportError:
        # no SSL available, so there is nothing to initialize
        return
    
    strongCiphers = [c for c in QSslSocket.supportedCiphers()
                     if c.name() not in blacklist and c.usedBits() >= 128]
    QSslSocket.setDefaultCiphers(strongCiphers)
开发者ID:testmana2,项目名称:test,代码行数:18,代码来源:E5SslUtilities.py

示例6: check_ssl_support

def check_ssl_support():
    """Check if SSL support is available."""
    try:
        from PyQt5.QtNetwork import QSslSocket
    except ImportError:
        ok = False
    else:
        ok = QSslSocket.supportsSsl()
    if not ok:
        text = "Fatal error: Your Qt is built without SSL support."
        _die(text)
开发者ID:B0073D,项目名称:qutebrowser,代码行数:11,代码来源:earlyinit.py

示例7: __getSystemCaCertificates

 def __getSystemCaCertificates(self):
     """
     Private method to get the list of system certificates.
     
     @return list of system certificates (list of QSslCertificate)
     """
     caList = QSslCertificate.fromData(Globals.toByteArray(
         Preferences.Prefs.settings.value("Ssl/SystemCertificates")))
     if not caList:
         caList = QSslSocket.systemCaCertificates()
     return caList
开发者ID:pycom,项目名称:EricShort,代码行数:11,代码来源:E5SslErrorHandler.py

示例8: init

def init():
    """Disable insecure SSL ciphers on old Qt versions."""
    if qtutils.version_check("5.3.0"):
        default_ciphers = QSslSocket.defaultCiphers()
        log.init.debug("Default Qt ciphers: {}".format(", ".join(c.name() for c in default_ciphers)))
    else:
        # https://codereview.qt-project.org/#/c/75943/
        default_ciphers = QSslSocket.supportedCiphers()
        log.init.debug("Supported Qt ciphers: {}".format(", ".join(c.name() for c in default_ciphers)))

    good_ciphers = []
    bad_ciphers = []
    for cipher in default_ciphers:
        if _is_secure_cipher(cipher):
            good_ciphers.append(cipher)
        else:
            bad_ciphers.append(cipher)

    log.init.debug("Disabling bad ciphers: {}".format(", ".join(c.name() for c in bad_ciphers)))
    QSslSocket.setDefaultCiphers(good_ciphers)
开发者ID:rumpelsepp,项目名称:qutebrowser,代码行数:20,代码来源:networkmanager.py

示例9: check_backend_ssl_support

def check_backend_ssl_support(backend):
    """Check for full SSL availability when we know the backend."""
    from PyQt5.QtNetwork import QSslSocket
    from qutebrowser.utils import log, usertypes
    text = ("Could not initialize QtNetwork SSL support. If you use "
            "OpenSSL 1.1 with a PyQt package from PyPI (e.g. on Archlinux "
            "or Debian Stretch), you need to set LD_LIBRARY_PATH to the path "
            "of OpenSSL 1.0. This only affects downloads.")

    if not QSslSocket.supportsSsl():
        if backend == usertypes.Backend.QtWebKit:
            _die("Could not initialize SSL support.")
        else:
            assert backend == usertypes.Backend.QtWebEngine
            log.init.warning(text)
开发者ID:swalladge,项目名称:qutebrowser,代码行数:15,代码来源:earlyinit.py

示例10: version

def version():
    """Return a string with various version informations."""
    lines = ["qutebrowser v{}".format(qutebrowser.__version__)]
    gitver = _git_str()
    if gitver is not None:
        lines.append("Git commit: {}".format(gitver))

    if qVersion() != QT_VERSION_STR:
        qt_version = "Qt: {} (compiled {})".format(qVersion(), QT_VERSION_STR)
    else:
        qt_version = "Qt: {}".format(qVersion())

    lines += [
        "",
        "{}: {}".format(platform.python_implementation(), platform.python_version()),
        qt_version,
        "PyQt: {}".format(PYQT_VERSION_STR),
        "",
    ]

    lines += _module_versions()

    lines += ["pdf.js: {}".format(_pdfjs_version())]

    if qWebKitVersion is None:
        lines.append("Webkit: no")
    else:
        lines.append("Webkit: {}".format(qWebKitVersion()))

    lines += ["SSL: {}".format(QSslSocket.sslLibraryVersionString()), ""]

    qapp = QApplication.instance()
    if qapp:
        style = qapp.style()
        lines.append("Style: {}".format(style.metaObject().className()))

    importpath = os.path.dirname(os.path.abspath(qutebrowser.__file__))

    lines += [
        "Platform: {}, {}".format(platform.platform(), platform.architecture()[0]),
        "Frozen: {}".format(hasattr(sys, "frozen")),
        "Imported from {}".format(importpath),
    ]
    lines += _os_info()
    return "\n".join(lines)
开发者ID:lahwaacz,项目名称:qutebrowser,代码行数:45,代码来源:version.py

示例11: handle

    def handle(self, argv: List[str]) -> int:
        """ Parse options, setup logs and manager and dispatch execution. """

        # Pre-configure the logging to catch early errors
        configure(console_level="DEBUG", command_name="early")

        options = self.parse_cli(argv)

        if hasattr(options, "local_folder"):
            options.local_folder = normalize_and_expand_path(options.local_folder)
        if hasattr(options, "nxdrive_home"):
            options.nxdrive_home = normalize_and_expand_path(options.nxdrive_home)

        command = getattr(options, "command", "launch")
        handler = getattr(self, command, None)
        if not handler:
            raise RuntimeError(f"No handler implemented for command {command}")

        self._configure_logger(command, options)

        log.info(f"Command line: argv={argv!r}, options={options!r}")
        log.info(f"Running on version {self.get_version()}")

        if QSslSocket:
            has_ssl_support = QSslSocket.supportsSsl()
            log.info(f"SSL support: {has_ssl_support!r}")
            if not has_ssl_support:
                if Options.is_frozen:
                    raise RuntimeError("No SSL support, packaging must have failed.")
                else:
                    options.ca_bundle = None
                    options.ssl_no_verify = True

        # We cannot use fail_on_error=True because options is a namespace
        # and contains a lot of inexistant Options values.
        Options.update(options, setter="cli", fail_on_error=False)

        if command != "uninstall":
            self._install_faulthandler()
            self.manager = self.get_manager()

        return handler(options)
开发者ID:nuxeo,项目名称:nuxeo-drive,代码行数:42,代码来源:commandline.py

示例12: version

def version(short=False):
    """Return a string with various version informations.

    Args:
        short: Return a shortened output.
    """
    lines = ["qutebrowser v{}".format(qutebrowser.__version__)]
    gitver = _git_str()
    if gitver is not None:
        lines.append("Git commit: {}".format(gitver))
    lines += [
        '',
        '{}: {}'.format(platform.python_implementation(),
                        platform.python_version()),
        'Qt: {}, runtime: {}'.format(QT_VERSION_STR, qVersion()),
        'PyQt: {}'.format(PYQT_VERSION_STR),
    ]

    if not short:
        style = QApplication.instance().style()
        lines += [
            'Style: {}'.format(style.metaObject().className()),
            'Desktop: {}'.format(os.environ.get('DESKTOP_SESSION')),
        ]

        lines += _module_versions()

        lines += [
            'pdf.js: {}'.format(_pdfjs_version()),
            'Webkit: {}'.format(qWebKitVersion()),
            'Harfbuzz: {}'.format(os.environ.get('QT_HARFBUZZ', 'system')),
            'SSL: {}'.format(QSslSocket.sslLibraryVersionString()),
            '',
            'Frozen: {}'.format(hasattr(sys, 'frozen')),
            'Platform: {}, {}'.format(platform.platform(),
                                      platform.architecture()[0]),
        ]
        lines += _os_info()
    return '\n'.join(lines)
开发者ID:Konubinix,项目名称:qutebrowser,代码行数:39,代码来源:version.py

示例13: _handle_ssl_support

def _handle_ssl_support(fatal=False):
    """Check for full SSL availability.

    If "fatal" is given, show an error and exit.
    """
    text = ("Could not initialize QtNetwork SSL support. If you use "
            "OpenSSL 1.1 with a PyQt package from PyPI (e.g. on Archlinux "
            "or Debian Stretch), you need to set LD_LIBRARY_PATH to the path "
            "of OpenSSL 1.0. This only affects downloads.")

    if QSslSocket.supportsSsl():
        return

    if fatal:
        errbox = msgbox.msgbox(parent=None,
                               title="SSL error",
                               text="Could not initialize SSL support.",
                               icon=QMessageBox.Critical,
                               plain_text=False)
        errbox.exec_()
        sys.exit(usertypes.Exit.err_init)

    assert not fatal
    log.init.warning(text)
开发者ID:blyxxyz,项目名称:qutebrowser,代码行数:24,代码来源:backendproblem.py

示例14: NetworkManager

# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with qutebrowser.  If not, see <http://www.gnu.org/licenses/>.

"""Our own QNetworkAccessManager."""

from PyQt5.QtCore import pyqtSlot, pyqtSignal, PYQT_VERSION, QCoreApplication
from PyQt5.QtNetwork import QNetworkAccessManager, QNetworkReply

try:
    from PyQt5.QtNetwork import QSslSocket
except ImportError:
    SSL_AVAILABLE = False
else:
    SSL_AVAILABLE = QSslSocket.supportsSsl()

from qutebrowser.config import config
from qutebrowser.utils import message, log, usertypes, utils, objreg
from qutebrowser.browser import cookies
from qutebrowser.browser.network import qutescheme, networkreply


HOSTBLOCK_ERROR_STRING = '%HOSTBLOCK%'


class NetworkManager(QNetworkAccessManager):

    """Our own QNetworkAccessManager.

    Attributes:
开发者ID:shaggytwodope,项目名称:aur,代码行数:31,代码来源:networkmanager.py

示例15: check_ssl

def check_ssl():
    if not QSslSocket.supportsSsl():
        pytest.skip("QtNetwork SSL not supported")
开发者ID:The-Compiler,项目名称:qutebrowser,代码行数:3,代码来源:test_downloads_bdd.py


注:本文中的PyQt5.QtNetwork.QSslSocket类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。