QSslDiffieHellmanParameters Class

QSslDiffieHellmanParameters 类为服务器的 Diffie-Hellman 参数提供了一个接口。更多

头文件: #include <QSslDiffieHellmanParameters>
CMake.QSslDiffieHellmanParameters 类 find_package(Qt6 REQUIRED COMPONENTS Network)
target_link_libraries(mytarget PRIVATE Qt6::Network)
qmake: QT += network

注意:该类中的所有函数都是可重入的

公共类型

enum Error { NoError, InvalidInputDataError, UnsafeParametersError }

公共函数

QSslDiffieHellmanParameters()
QSslDiffieHellmanParameters(const QSslDiffieHellmanParameters &other)
QSslDiffieHellmanParameters(QSslDiffieHellmanParameters &&other)
~QSslDiffieHellmanParameters()
QSslDiffieHellmanParameters::Error error() const
QString errorString() const
bool isEmpty() const
bool isValid() const
void swap(QSslDiffieHellmanParameters &other)
QSslDiffieHellmanParameters &operator=(QSslDiffieHellmanParameters &&other)
QSslDiffieHellmanParameters &operator=(const QSslDiffieHellmanParameters &other)

静态公共成员

QSslDiffieHellmanParameters defaultParameters()
QSslDiffieHellmanParameters fromEncoded(QIODevice *device, QSsl::EncodingFormat encoding = QSsl::Pem)
QSslDiffieHellmanParameters fromEncoded(const QByteArray &encoded, QSsl::EncodingFormat encoding = QSsl::Pem)
size_t qHash(const QSslDiffieHellmanParameters &key, size_t seed = 0)
bool operator!=(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs)
QDebug operator<<(QDebug debug, const QSslDiffieHellmanParameters &dhparam)
bool operator==(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs)

详细说明

QSslDiffieHellmanParameters 提供了一个接口,用于基于QSslSocket 为服务器设置 Diffie-Hellman 参数。

另请参见 QSslSocket,QSslCipher, 和QSslConfiguration

成员类型文档

enum QSslDiffieHellmanParameters::Error

描述QSslDiffieHellmanParameters 错误。

常量说明
QSslDiffieHellmanParameters::NoError0未发生错误。
QSslDiffieHellmanParameters::InvalidInputDataError1给定的输入数据不能用于构造QSslDiffieHellmanParameters 对象。
QSslDiffieHellmanParameters::UnsafeParametersError2Diffie-Hellman 参数不安全,不应使用。

成员函数文档

QSslDiffieHellmanParameters::QSslDiffieHellmanParameters()

构造一个空 QSslDiffieHellmanParameters 实例。

如果在QSslConfiguration 对象上设置了一个空的 QSslDiffieHellmanParameters 实例,则 Diffie-Hellman 协商将被禁用。

另请参阅 isValid() 和QSslConfiguration

QSslDiffieHellmanParameters::QSslDiffieHellmanParameters(const QSslDiffieHellmanParameters &other)

构建一个与other 完全相同的副本。

[noexcept] QSslDiffieHellmanParameters::QSslDiffieHellmanParameters(QSslDiffieHellmanParameters &&other)

Move-constructs fromother

注: moved-from 对象other 处于部分形成状态,其中唯一有效的操作是销毁和赋新值。

[noexcept] QSslDiffieHellmanParameters::~QSslDiffieHellmanParameters()

销毁QSslDiffieHellmanParameters 对象。

[static] QSslDiffieHellmanParameters QSslDiffieHellmanParameters::defaultParameters()

返回QSslSocket 使用的默认QSslDiffieHellmanParameters

目前使用的是 RFC 3526 中的 2048 位 MODP 组。

[noexcept] QSslDiffieHellmanParameters::Error QSslDiffieHellmanParameters::error() const

返回导致QSslDiffieHellmanParameters 对象无效的错误信息。

[noexcept] QString QSslDiffieHellmanParameters::errorString() const

返回导致QSslDiffieHellmanParameters 对象无效的错误的可读描述。

[static] QSslDiffieHellmanParameters QSslDiffieHellmanParameters::fromEncoded(QIODevice *device, QSsl::EncodingFormat encoding = QSsl::Pem)

通过从device 读取encoding 所指定的 PEM 或 DER 格式,构建QSslDiffieHellmanParameters 对象。

在返回的对象上使用isValid() 方法检查 Diffie-Hellman 参数是否有效和加载是否正确。

特别是,如果devicenullptr 或未开放读取,将返回一个无效对象。

另请参阅 isValid() 和QSslConfiguration

[static] QSslDiffieHellmanParameters QSslDiffieHellmanParameters::fromEncoded(const QByteArray &encoded, QSsl::EncodingFormat encoding = QSsl::Pem)

使用由encoding 指定的 PEM 或 DER 格式字节数组encoded 构造QSslDiffieHellmanParameters 对象。

在返回的对象上使用isValid() 方法检查 Diffie-Hellman 参数是否有效和加载是否正确。

另请参阅 isValid() 和QSslConfiguration

[noexcept] bool QSslDiffieHellmanParameters::isEmpty() const

如果是空QSslDiffieHellmanParameters 实例,则返回true

在基于QSslSocket 的服务器上设置一个空的QSslDiffieHellmanParameters 实例将禁用 Diffie-Hellman 密钥交换。

[noexcept] bool QSslDiffieHellmanParameters::isValid() const

如果这是一个有效的QSslDiffieHellmanParameters ,则返回true ;否则返回 false。

该方法应在构造QSslDiffieHellmanParameters 对象后使用,以确定其有效性。

如果QSslDiffieHellmanParameters 对象无效,可以使用error() 方法确定是什么错误导致无法构造该对象。

另请参阅 error()。

[noexcept] void QSslDiffieHellmanParameters::swap(QSslDiffieHellmanParameters &other)

QSslDiffieHellmanParametersother 互换。这一操作非常快速,而且从未出现过故障。

[noexcept] QSslDiffieHellmanParameters &QSslDiffieHellmanParameters::operator=(QSslDiffieHellmanParameters &&other)

移动--将other 赋值给此QSslDiffieHellmanParameters 实例。

注意: 从移动对象other 将处于部分形成状态,其中唯一有效的操作是销毁和赋新值。

QSslDiffieHellmanParameters &QSslDiffieHellmanParameters::operator=(const QSslDiffieHellmanParameters &other)

other 的内容复制到此QSslDiffieHellmanParameters 中,使两个QSslDiffieHellmanParameters 相同。

返回对QSslDiffieHellmanParameters 的引用。

相关非会员

[noexcept] size_t qHash(const QSslDiffieHellmanParameters &key, size_t seed = 0)

返回key 的哈希值,使用seed 作为计算的种子。

[noexcept] bool operator!=(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs)

如果lhs 不等于rhs ,则返回true ;否则返回false

QDebug operator<<(QDebug debug, const QSslDiffieHellmanParameters &dhparam)

dhparam 中的 Diffie-Hellman 参数集写入调试对象debug ,以便调试。

Diffie-Hellman 参数将以 Base64 编码的 DER 形式表示。

另请参阅 调试技术

[noexcept] bool operator==(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs)

如果lhs 等于rhs ,则返回true ;否则返回false

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.