QSsl Namespace

QSsl 命名空间为所有的 SSL 类声明了通用的枚举类型. More...

头文件: #include <QSsl>
qmake: QT += network
开始支持版本: Qt 4.3

Types

enum AlternativeNameEntryType { EmailEntry, DnsEntry, IpAddressEntry }
enum EncodingFormat { Pem, Der }
enum KeyAlgorithm { Rsa, Dsa, Ec, Dh, Opaque }
enum KeyType { PrivateKey, PublicKey }
enum SslOption { SslOptionDisableEmptyFragments, SslOptionDisableSessionTickets, SslOptionDisableCompression, SslOptionDisableServerNameIndication, SslOptionDisableLegacyRenegotiation, …, SslOptionDisableServerCipherPreference }
flags SslOptions
enum SslProtocol { SslV3, SslV2, TlsV1_0, TlsV1_0OrLater, TlsV1, …, SecureProtocols }

详细描述

Type Documentation

enum QSsl::AlternativeNameEntryType

描述 QSslCertificate 中条目的可替代名称的键类型.

ConstantValueDescription
QSsl::EmailEntry0电子邮件条目; 该条目中包含证书有效的电子邮件地址.
QSsl::DnsEntry1DNS 主机名条目. 该条目包含证书有效的主机名条目.
QSsl::IpAddressEntry2IP 地址条目. 该条目包含 Qt 5.13 中引入的证书有效的 IP 地址条目.

注意: 在 Qt 4中, 这个枚举被叫做 AlternateNameEntryType. 这个名称在 Qt 5 中已不被推荐使用.

另见 QSslCertificate::subjectAlternativeNames().

enum QSsl::EncodingFormat

描述证书和密钥支持的编码类型.

ConstantValueDescription
QSsl::Pem0 PEM 格式.
QSsl::Der1 DER 格式.

enum QSsl::KeyAlgorithm

描述了 QSslKey 支持的不同的密钥加密算法.

ConstantValueDescription
QSsl::Rsa1 RSA 算法.
QSsl::Dsa2 DSA 算法.
QSsl::Ec3 椭圆曲线算法.
QSsl::Dh4 Diffie-Hellman 算法.
QSsl::Opaque0 密钥将被 QSslKey 作为黑匣子.

不透明的密钥功能 ( QSsl::Opaque ) 允许应用程序添加对 Qt 当前不提供的功能 ( 例如 PKCS#11 ) 的支持.

enum QSsl::KeyType

描述了 QSslKey 支持的两种密钥类型.

ConstantValueDescription
QSsl::PrivateKey0 私钥.
QSsl::PublicKey1 公钥.

enum QSsl::SslOption
flags QSsl::SslOptions

描述可用于控制 SSL 详细行为的选项. 这些选项通常用于关闭功能以解决有问题的服务器.

ConstantValueDescription
QSsl::SslOptionDisableEmptyFragments0x01使用分组密码时, 禁止将空片段插入数据中. 启用该选项后, 这可以防止某些攻击 ( 例如 BEAST 攻击), 但是与某些服务器不兼容.
QSsl::SslOptionDisableSessionTickets0x02禁用 SSL 会话票证扩展. 这可能会导致连接设置变慢, 但是某些服务器不兼容该扩展.
QSsl::SslOptionDisableCompression0x04禁用 SSL 压缩扩展. 启用该功能后, 这将允许压缩通过 SSL 传递的数据, 但是某些服务器与此扩展不兼容.
QSsl::SslOptionDisableServerNameIndication0x08禁用SSL服务器名称指示扩展名. 启用后, 它会告知服务器正在访问的虚拟主机, 从而使其可以使用正确的证书进行响应.
QSsl::SslOptionDisableLegacyRenegotiation0x10禁用用于重新协商连接参数的较旧的不安全机制. 启用后, 此选项可以允许旧服务器连接, 但是它带来了攻击者可能将纯文本注入 SSL 会话的可能性.
QSsl::SslOptionDisableSessionSharing0x20通过会话 ID 握手属性禁用 SSL 会话共享.
QSsl::SslOptionDisableSessionPersistence0x40禁用以 QSslConfiguration::sessionTicket() 返回的 ASN.1 格式存储 SSL 会话. 启用此功能会为每个使用的会话票证增加大约1K的内存开销.
QSsl::SslOptionDisableServerCipherPreference0x80禁用基于服务器首选项而非客户端发送的顺序密码来选择所选密码的功能. 此选项仅与服务器套接字相关, 并且仅由 OpenSSL 后端使用.

默认情况下, SslOptionDisableEmptyFragments 选项处于启用状态, 因为这会导致大量服务器出现问题. SslOptionDisableLegacyRenegotiation 选项也处于启用状态, 因为它带来了安全风险. 启用 SslOptionDisableCompression 可以防止 CRIME 公开攻击. SslOptionDisableSessionPersistence 也处于启用状态以优化内存使用. 其他选项处于关闭状态.

注意: 以上选项的可用性取决于所使用的 SSL 后端的版本.

The SslOptions type is a typedef for QFlags<SslOption>. It stores an OR combination of SslOption values.

enum QSsl::SslProtocol

Describes the protocol of the cipher.

ConstantValueDescription
QSsl::SslV30SSLv3; not supported by QSslSocket.
QSsl::SslV21SSLv2; not supported by QSslSocket.
QSsl::TlsV1_02TLSv1.0
QSsl::TlsV1_0OrLater8TLSv1.0 and later versions. This option is not available when using the WinRT backend due to platform limitations.
QSsl::TlsV1TlsV1_0Obsolete, means the same as TlsV1_0
QSsl::TlsV1_13TLSv1.1. When using the WinRT backend this option will also enable TLSv1.0.
QSsl::TlsV1_1OrLater9TLSv1.1 and later versions. This option is not available when using the WinRT backend due to platform limitations.
QSsl::TlsV1_24TLSv1.2. When using the WinRT backend this option will also enable TLSv1.0 and TLSv1.1.
QSsl::TlsV1_2OrLater10TLSv1.2 and later versions. This option is not available when using the WinRT backend due to platform limitations.
QSsl::DtlsV1_011DTLSv1.0
QSsl::DtlsV1_0OrLater12DTLSv1.0 and later versions.
QSsl::DtlsV1_213DTLSv1.2
QSsl::DtlsV1_2OrLater14DTLSv1.2 and later versions.
QSsl::TlsV1_315TLSv1.3. (Since Qt 5.12)
QSsl::TlsV1_3OrLater16TLSv1.3 and later versions. (Since Qt 5.12)
QSsl::UnknownProtocol-1The cipher's protocol cannot be determined.
QSsl::AnyProtocol5Any supported protocol. This value is used by QSslSocket only.
QSsl::TlsV1SslV36Same as TlsV1_0. This enumerator is deprecated, use TlsV1_0 instead.
QSsl::SecureProtocolsAnyProtocol + 2The default option, using protocols known to be secure.