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 中条目的可替代名称的键类型.
Constant | Value | Description |
---|---|---|
QSsl::EmailEntry | 0 | 电子邮件条目; 该条目中包含证书有效的电子邮件地址. |
QSsl::DnsEntry | 1 | DNS 主机名条目. 该条目包含证书有效的主机名条目. |
QSsl::IpAddressEntry | 2 | IP 地址条目. 该条目包含 Qt 5.13 中引入的证书有效的 IP 地址条目. |
注意: 在 Qt 4中, 这个枚举被叫做 AlternateNameEntryType
. 这个名称在 Qt 5 中已不被推荐使用.
另见 QSslCertificate::subjectAlternativeNames().
enum QSsl::EncodingFormat
描述证书和密钥支持的编码类型.
Constant | Value | Description |
---|---|---|
QSsl::Pem | 0 | PEM 格式. |
QSsl::Der | 1 | DER 格式. |
enum QSsl::KeyAlgorithm
描述了 QSslKey 支持的不同的密钥加密算法.
Constant | Value | Description |
---|---|---|
QSsl::Rsa | 1 | RSA 算法. |
QSsl::Dsa | 2 | DSA 算法. |
QSsl::Ec | 3 | 椭圆曲线算法. |
QSsl::Dh | 4 | Diffie-Hellman 算法. |
QSsl::Opaque | 0 | 密钥将被 QSslKey 作为黑匣子. |
不透明的密钥功能 ( QSsl::Opaque ) 允许应用程序添加对 Qt 当前不提供的功能 ( 例如 PKCS#11 ) 的支持.
enum QSsl::KeyType
描述了 QSslKey 支持的两种密钥类型.
Constant | Value | Description |
---|---|---|
QSsl::PrivateKey | 0 | 私钥. |
QSsl::PublicKey | 1 | 公钥. |
enum QSsl::SslOption
flags QSsl::SslOptions
描述可用于控制 SSL 详细行为的选项. 这些选项通常用于关闭功能以解决有问题的服务器.
Constant | Value | Description |
---|---|---|
QSsl::SslOptionDisableEmptyFragments | 0x01 | 使用分组密码时, 禁止将空片段插入数据中. 启用该选项后, 这可以防止某些攻击 ( 例如 BEAST 攻击), 但是与某些服务器不兼容. |
QSsl::SslOptionDisableSessionTickets | 0x02 | 禁用 SSL 会话票证扩展. 这可能会导致连接设置变慢, 但是某些服务器不兼容该扩展. |
QSsl::SslOptionDisableCompression | 0x04 | 禁用 SSL 压缩扩展. 启用该功能后, 这将允许压缩通过 SSL 传递的数据, 但是某些服务器与此扩展不兼容. |
QSsl::SslOptionDisableServerNameIndication | 0x08 | 禁用SSL服务器名称指示扩展名. 启用后, 它会告知服务器正在访问的虚拟主机, 从而使其可以使用正确的证书进行响应. |
QSsl::SslOptionDisableLegacyRenegotiation | 0x10 | 禁用用于重新协商连接参数的较旧的不安全机制. 启用后, 此选项可以允许旧服务器连接, 但是它带来了攻击者可能将纯文本注入 SSL 会话的可能性. |
QSsl::SslOptionDisableSessionSharing | 0x20 | 通过会话 ID 握手属性禁用 SSL 会话共享. |
QSsl::SslOptionDisableSessionPersistence | 0x40 | 禁用以 QSslConfiguration::sessionTicket() 返回的 ASN.1 格式存储 SSL 会话. 启用此功能会为每个使用的会话票证增加大约1K的内存开销. |
QSsl::SslOptionDisableServerCipherPreference | 0x80 | 禁用基于服务器首选项而非客户端发送的顺序密码来选择所选密码的功能. 此选项仅与服务器套接字相关, 并且仅由 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.
Constant | Value | Description |
---|---|---|
QSsl::SslV3 | 0 | SSLv3; not supported by QSslSocket. |
QSsl::SslV2 | 1 | SSLv2; not supported by QSslSocket. |
QSsl::TlsV1_0 | 2 | TLSv1.0 |
QSsl::TlsV1_0OrLater | 8 | TLSv1.0 and later versions. This option is not available when using the WinRT backend due to platform limitations. |
QSsl::TlsV1 | TlsV1_0 | Obsolete, means the same as TlsV1_0 |
QSsl::TlsV1_1 | 3 | TLSv1.1. When using the WinRT backend this option will also enable TLSv1.0. |
QSsl::TlsV1_1OrLater | 9 | TLSv1.1 and later versions. This option is not available when using the WinRT backend due to platform limitations. |
QSsl::TlsV1_2 | 4 | TLSv1.2. When using the WinRT backend this option will also enable TLSv1.0 and TLSv1.1. |
QSsl::TlsV1_2OrLater | 10 | TLSv1.2 and later versions. This option is not available when using the WinRT backend due to platform limitations. |
QSsl::DtlsV1_0 | 11 | DTLSv1.0 |
QSsl::DtlsV1_0OrLater | 12 | DTLSv1.0 and later versions. |
QSsl::DtlsV1_2 | 13 | DTLSv1.2 |
QSsl::DtlsV1_2OrLater | 14 | DTLSv1.2 and later versions. |
QSsl::TlsV1_3 | 15 | TLSv1.3. (Since Qt 5.12) |
QSsl::TlsV1_3OrLater | 16 | TLSv1.3 and later versions. (Since Qt 5.12) |
QSsl::UnknownProtocol | -1 | The cipher's protocol cannot be determined. |
QSsl::AnyProtocol | 5 | Any supported protocol. This value is used by QSslSocket only. |
QSsl::TlsV1SslV3 | 6 | Same as TlsV1_0. This enumerator is deprecated, use TlsV1_0 instead. |
QSsl::SecureProtocols | AnyProtocol + 2 | The default option, using protocols known to be secure. |