本文整理汇总了Python中PyQt5.QtNetwork.QSslSocket.setDefaultCiphers方法的典型用法代码示例。如果您正苦于以下问题:Python QSslSocket.setDefaultCiphers方法的具体用法?Python QSslSocket.setDefaultCiphers怎么用?Python QSslSocket.setDefaultCiphers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtNetwork.QSslSocket
的用法示例。
在下文中一共展示了QSslSocket.setDefaultCiphers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init
# 需要导入模块: from PyQt5.QtNetwork import QSslSocket [as 别名]
# 或者: from PyQt5.QtNetwork.QSslSocket import setDefaultCiphers [as 别名]
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)
示例2: init
# 需要导入模块: from PyQt5.QtNetwork import QSslSocket [as 别名]
# 或者: from PyQt5.QtNetwork.QSslSocket import setDefaultCiphers [as 别名]
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)
示例3: initSSL
# 需要导入模块: from PyQt5.QtNetwork import QSslSocket [as 别名]
# 或者: from PyQt5.QtNetwork.QSslSocket import setDefaultCiphers [as 别名]
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)
示例4: init
# 需要导入模块: from PyQt5.QtNetwork import QSslSocket [as 别名]
# 或者: from PyQt5.QtNetwork.QSslSocket import setDefaultCiphers [as 别名]
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)