本页内容

QOcspResponse Class

该类表示在线证书状态协议(OCSP)的响应。更多内容...

头文件: #include <QOcspResponse>
CMake: find_package(Qt6 REQUIRED COMPONENTS Network)
target_link_libraries(mytarget PRIVATE Qt6::Network)
qmake: QT += network

公共函数

QOcspResponse()
QOcspResponse(const QOcspResponse &other)
QOcspResponse(QOcspResponse &&other)
~QOcspResponse()
QOcspCertificateStatus certificateStatus() const
class QSslCertificate responder() const
QOcspRevocationReason revocationReason() const
QSslCertificate subject() const
void swap(QOcspResponse &other)
QOcspResponse &operator=(QOcspResponse &&other)
QOcspResponse &operator=(const QOcspResponse &other)
enum class QOcspCertificateStatus { Good, Revoked, Unknown }
enum class QOcspRevocationReason { None, Unspecified, KeyCompromise, CACompromise, AffiliationChanged, …, RemoveFromCRL }
bool operator!=(const QOcspResponse &lhs, const QOcspResponse &rhs)
bool operator==(const QOcspResponse &lhs, const QOcspResponse &rhs)

详细说明

QOcspResponse 类表示服务器证书的撤销状态,该状态由客户端套接字在 TLS 握手期间接收。必须将QSslSocket 配置为启用 OCSP 钉合。

另请参阅 QSslSocket 、QSslSocket::ocspResponses()、certificateStatus()、revocationReason()、responder()、subject()、QOcspCertificateStatus 、QOcspRevocationReason 、QSslConfiguration::setOcspStaplingEnabled()、QSslConfiguration::ocspStaplingEnabled() 和QSslConfiguration::peerCertificate()。

成员函数文档

QOcspResponse::QOcspResponse()

创建一个新的响应,状态为QOcspCertificateStatus::Unknown ,撤销原因为QOcspRevocationReason::None 。

另请参阅 QOcspCertificateStatus 。

QOcspResponse::QOcspResponse(const QOcspResponse &other)

复制并构造一个 QOcspResponse 实例。

[noexcept] QOcspResponse::QOcspResponse(QOcspResponse &&other)

通过 Move 构造一个 QOcspResponse 实例。

[noexcept] QOcspResponse::~QOcspResponse()

销毁该响应。

QOcspCertificateStatus QOcspResponse::certificateStatus() const

返回证书状态。

另请参阅 QOcspCertificateStatus 。

class QSslCertificate QOcspResponse::responder() const

该函数返回用于签署 OCSP 响应的证书。

QOcspRevocationReason QOcspResponse::revocationReason() const

返回撤销的原因。

QSslCertificate QOcspResponse::subject() const

该函数返回一个证书,此响应正是为此证书签发的。

[noexcept] void QOcspResponse::swap(QOcspResponse &other)

将此响应与other 进行交换。此操作速度极快,且绝不会失败。

[noexcept] QOcspResponse &QOcspResponse::operator=(QOcspResponse &&other)

将other 赋值给此QOcspResponse 实例。

QOcspResponse &QOcspResponse::operator=(const QOcspResponse &other)

通过复制赋值将other 赋值给该响应,并返回对此响应的引用。

相关非成员

enum class QOcspCertificateStatus

描述在线证书状态

常量值描述
QOcspResponse::QOcspCertificateStatus::Good0该证书未被吊销,但这并不一定意味着该证书曾被颁发,也不一定意味着生成响应时处于证书的有效期内。
QOcspResponse::QOcspCertificateStatus::Revoked1此状态表示证书已被吊销(无论是永久吊销还是暂时吊销——处于暂停状态)。
QOcspResponse::QOcspCertificateStatus::Unknown2此状态表示响应方不知道所请求的证书。

另请参阅 QOcspRevocationReason 。

enum class QOcspRevocationReason

描述撤销的原因

此枚举描述了RFC 5280第5.3.1节中定义的撤销原因

常量值
QOcspResponse::QOcspRevocationReason::None-1
QOcspResponse::QOcspRevocationReason::Unspecified0
QOcspResponse::QOcspRevocationReason::KeyCompromise1
QOcspResponse::QOcspRevocationReason::CACompromise2
QOcspResponse::QOcspRevocationReason::AffiliationChanged3
QOcspResponse::QOcspRevocationReason::Superseded4
QOcspResponse::QOcspRevocationReason::CessationOfOperation5
QOcspResponse::QOcspRevocationReason::CertificateHold6
QOcspResponse::QOcspRevocationReason::RemoveFromCRL7

bool operator!=(const QOcspResponse &lhs, const QOcspResponse &rhs)

如果lhs 和rhs 对应的响应来自不同的证书、由不同的签名方签名、具有不同的撤销原因或不同的证书状态,则返回true 。

bool operator==(const QOcspResponse &lhs, const QOcspResponse &rhs)

如果lhs 和rhs 针对同一张证书,且由同一响应方签名、具有相同的撤销原因和相同的证书状态,则返回true 。

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