QSslCertificateExtension Class

QSslCertificateExtension 类提供了访问 X509 证书扩展的 API。更多

Header: #include <QSslCertificateExtension>
CMake: find_package(Qt6 REQUIRED COMPONENTS Network)
target_link_libraries(mytarget PRIVATE Qt6::Network)
qmake: QT += network

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

公共函数

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 证书扩展都有以下属性:

属性属性
名称扩展名的可读名称,如 "basicConstraints"。
关键性布尔值,表示扩展对正确解释证书是否至关重要。
oidASN.1 对象标识符,用于指明这是哪个扩展。
支持如果为 true,扩展值的结构在不同 Qt 版本之间不会改变。
一个QVariant ,其结构取决于扩展类型。

虽然该类可以访问任何类型的扩展,但只有部分扩展的返回格式在不同版本之间保持不变。在这种情况下,isSupported() 方法将返回扩展名的true

目前支持的扩展名以及返回值的结构如下:

名称OID详细信息
基本约束2.5.29.19QVariantMap 的形式返回。键 "ca "包含一个布尔值,可选键 "pathLenConstraint "包含一个整数。
权限信息访问1.3.6.1.5.5.7.1.1QVariantMap 的形式返回。每种访问方法都有一个键,键值为 URI。
主题键标识符2.5.29.14以包含QStringQVariant 的形式返回。字符串是关键标识符。
authorityKeyIdentifier2.5.29.35QVariantMap 的形式返回。可选键 "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 分配给该分机,并返回对该分机的引用。

© 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.