QWebEngineCertificateError Class

QWebEngineCertificateError 类提供有关证书错误的信息。更多

Header: #include <QWebEngineCertificateError>
CMake: find_package(Qt6 REQUIRED COMPONENTS WebEngineCore)
target_link_libraries(mytarget PRIVATE Qt6::WebEngineCore)
qmake: QT += webenginecore
在 QML 中: WebEngineCertificateError

公共类型

enum Type { SslPinnedKeyNotInCertificateChain, CertificateCommonNameInvalid, CertificateDateInvalid, CertificateAuthorityInvalid, CertificateContainsErrors, …, CertificateSymantecLegacy }

属性

公共功能

void acceptCertificate()
QList<QSslCertificate> certificateChain() const
void defer()
QString description() const
bool isMainFrame() const
bool isOverridable() const
void rejectCertificate()
QWebEngineCertificateError::Type type() const
QUrl url() const

详细说明

提供有关证书错误的信息。该类用作QWebEnginePage::certificateError() 的参数。

成员类型文档

enum QWebEngineCertificateError::Type

该枚举描述了遇到的证书错误类型。

该枚举类型的值与 Chromium 提供的 SSL 错误相匹配。由于 Qt XML 错误类别无法映射到 Chromium 错误类别,因此不能直接使用QSslError::SslError 值。

常量说明
QWebEngineCertificateError::SslPinnedKeyNotInCertificateChain-150证书与主机名的内置公钥不匹配。
QWebEngineCertificateError::CertificateCommonNameInvalid-200证书的通用名称与主机名不匹配。
QWebEngineCertificateError::CertificateDateInvalid-201证书在当前日期和时间无效。
QWebEngineCertificateError::CertificateAuthorityInvalid-202证书未由可信机构签署。
QWebEngineCertificateError::CertificateContainsErrors-203证书包含错误。
QWebEngineCertificateError::CertificateNoRevocationMechanism-204证书没有确定是否已被吊销的机制。
QWebEngineCertificateError::CertificateUnableToCheckRevocation-205证书的撤销信息不可用。
QWebEngineCertificateError::CertificateRevoked-206证书已被废止。
QWebEngineCertificateError::CertificateInvalid-207证书无效。
QWebEngineCertificateError::CertificateWeakSignatureAlgorithm-208证书使用弱签名算法签名。
QWebEngineCertificateError::CertificateNonUniqueName-210证书中指定的主机名不唯一。
QWebEngineCertificateError::CertificateWeakKey-211证书包含弱密钥。
QWebEngineCertificateError::CertificateNameConstraintViolation-212证书声称的 DNS 名称违反名称限制。
QWebEngineCertificateError::CertificateValidityTooLong-213证书有效期过长。(在 Qt 5.7 中添加)
QWebEngineCertificateError::CertificateTransparencyRequired-214此连接需要证书透明度,但服务器没有提供符合策略的 CT 信息。(已在 Qt 5.8 中添加)
QWebEngineCertificateError::CertificateKnownInterceptionBlocked-217已知证书被设备所有者以外的实体用于拦截。(已在 5.15 中添加)
QWebEngineCertificateError::SslObsoleteVersion-218连接使用了过时的 SSL/TLS 版本。(在 Qt 6.2 中已添加,在 Qt 6.4 中已弃用)
QWebEngineCertificateError::CertificateSymantecLegacy-215证书是不再有效的赛门铁克传统证书。(在 Qt 6.2 中已添加)

属性文档

[read-only, since 6.8] isMainFrame : const bool

返回证书错误是否来自主框架。如果为 false,则错误来自子资源,很可能需要在没有用户输入的情况下予以拒绝。

此属性在 Qt 6.8 中引入。

访问函数:

bool isMainFrame() const

[read-only] overridable : const bool

此属性表示是否可以重载和接受此错误。

访问函数:

bool isOverridable() const

另请参见 description().

成员函数文档

[invokable] void QWebEngineCertificateError::acceptCertificate()

接受证书并继续加载请求的 URL。

注: 可通过元对象系统和 QML 调用该函数。请参阅Q_INVOKABLE

QList<QSslCertificate> QWebEngineCertificateError::certificateChain() const

返回同行的数字证书链。

链以对等方的直接证书开始,以 CA 的证书结束。

[invokable] void QWebEngineCertificateError::defer()

标记证书错误,以便延迟处理。

当需要推迟决定是否接受证书时,例如等待用户输入时,应调用此函数。调用该函数时,URL 请求会暂停,直到acceptCertificate() 或rejectCertificate() 被调用。

注: 只能推迟可覆盖的证书错误。

注: 可通过元对象系统和 QML 调用该函数。请参阅Q_INVOKABLE

另请参阅 isOverridable() 。

QString QWebEngineCertificateError::description() const

返回错误的简短本地化人可读描述。

注: 属性描述的获取函数。

另请参阅 url() 和isOverridable()。

[invokable] void QWebEngineCertificateError::rejectCertificate()

拒绝证书并放弃加载请求的 URL。

注: 可通过元对象系统和 QML 调用该函数。请参阅Q_INVOKABLE

QWebEngineCertificateError::Type QWebEngineCertificateError::type() const

返回错误类型。

注: 属性类型的获取函数。

另请参阅 description() 和isOverridable()。

QUrl QWebEngineCertificateError::url() const

返回引发错误的 URL。

注: 属性 url 的获取函数。

另请参阅 description().

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