QSslCertificateExtension Class
QSslCertificateExtension 类提供了一个用于访问 X509 证书扩展的 API。更多内容...
| 头文件: | #include <QSslCertificateExtension> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Network) target_link_libraries(mytarget PRIVATE Qt6::Network) |
| qmake: | QT += network |
- 所有成员的列表,包括继承的成员
- QSslCertificateExtension 属于“网络编程 API”和“隐式共享类”的一部分。
注意:该类中的所有函数均为可重入函数。
公共函数
| QSslCertificateExtension() | |
| QSslCertificateExtension(const QSslCertificateExtension &other) | |
| ~QSslCertificateExtension() | |
| bool | isCritical() const |
| bool | isSupported() const |
| QString | name() const |
| QString | oid() const |
| void | swap(QSslCertificateExtension &other) |
| QVariant | value() const |
| QSslCertificateExtension & | operator=(const QSslCertificateExtension &other) |
详细说明
QSslCertificateExtension 提供对存储在 X509 证书中的扩展的访问。可用的信息取决于所访问的扩展类型。
所有 X509 证书扩展都具有以下属性:
| 属性 | 描述 |
|---|---|
| name | 扩展的人类可读名称,例如“basicConstraints”。 |
| 关键性 | 这是一个布尔值,用于指示该扩展对于正确解析证书是否至关重要。 |
| oid | 指定该扩展的 ASN.1 对象标识符。 |
| supported | 如果该值为 true,则该扩展值的结构在不同 Qt 版本之间不会发生变化。 |
| value | 一个 `QVariant `,其结构取决于扩展的类型。 |
虽然该类提供了对任何类型扩展的访问,但只有部分扩展能保证以在各版本之间保持不变的格式返回。对于符合此条件的扩展,isSupported() 方法将返回true 。
当前支持的扩展及其返回值的结构如下:
| 名称 | OID | 详细信息 |
|---|---|---|
| basicConstraints | 2.5.29.19 | 以QVariantMap 的形式返回。键“ca”包含一个布尔值,可选键“pathLenConstraint”包含一个整数。 |
| authorityInfoAccess | 1.3.6.1.5.5.7.1.1 | 以QVariantMap 的形式返回。每种访问方法对应一个键,其值为一个URI。 |
| subjectKeyIdentifier | 2.5.29.14 | 以QVariant 的形式返回,其中包含QString 。该字符串即为密钥标识符。 |
| authorityKeyIdentifier | 2.5.29.35 | 以QVariantMap 格式返回。可选键“keyid”包含密钥标识符,该标识符以十六进制字符串形式存储在QByteArray 中。可选键“serial”包含授权密钥序列号,类型为qlonglong。目前不支持此扩展的一般名称字段。 |
除了上述受支持的扩展外,许多其他常见扩展也将以合理结构化的方式返回。SSL后端完全不支持的扩展将作为QByteArray 返回。
有关证书可能包含的扩展类型的更多信息,请参阅 RFC 5280。
另请参阅 QSslCertificate::extensions()。
成员函数文档
QSslCertificateExtension::QSslCertificateExtension()
创建一个 QSslCertificateExtension 对象。
QSslCertificateExtension::QSslCertificateExtension(const QSslCertificateExtension &other)
创建other 的一个副本。
[noexcept] QSslCertificateExtension::~QSslCertificateExtension()
删除该扩展程序。
bool QSslCertificateExtension::isCritical() const
返回该扩展的严重性级别。
bool QSslCertificateExtension::isSupported() const
如果支持此扩展,则返回 true。在此情况下,“支持”仅意味着value() 访问器返回的QVariant 的结构在不同版本之间保持不变。不支持的扩展可以自由使用,但无法保证不同版本之间返回的数据结构保持一致。
QString QSslCertificateExtension::name() const
返回扩展的名称。如果该扩展的名称未知,则返回其 OID。
QString QSslCertificateExtension::oid() const
返回此扩展的 ASN.1 OID。
[noexcept] void QSslCertificateExtension::swap(QSslCertificateExtension &other)
将此证书扩展实例与other 互换。此操作速度极快,且绝不会失败。
QVariant QSslCertificateExtension::value() const
返回扩展的值。返回值的结构取决于扩展的类型。
QSslCertificateExtension &QSslCertificateExtension::operator=(const QSslCertificateExtension &other)
将other 分配给此扩展,并返回对此扩展的引用。
© 2026 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.