本页内容

QCoapPrivateKey Class

QCoapPrivateKey 类提供了一个用于管理 CoAP 安全密钥的接口。更多内容...

头文件: #include <QCoapPrivateKey>
CMake: find_package(Qt6 REQUIRED COMPONENTS Coap)
target_link_libraries(mytarget PRIVATE Qt6::Coap)
qmake: QT += coap

公共函数

QCoapPrivateKey()
QCoapPrivateKey(const Qt::HANDLE &handle)
QCoapPrivateKey(const QByteArray &key, QSsl::KeyAlgorithm algorithm, QSsl::EncodingFormat format = QSsl::Pem, const QByteArray &passPhrase = QByteArray())
QCoapPrivateKey(const QCoapPrivateKey &other)
QCoapPrivateKey(QCoapPrivateKey &&other)
~QCoapPrivateKey()
QSsl::KeyAlgorithm algorithm() const
QSsl::EncodingFormat encodingFormat() const
Qt::HANDLE handle() const
bool isNull() const
QByteArray key() const
QByteArray passPhrase() const
void swap(QCoapPrivateKey &other)
QCoapPrivateKey &operator=(const QCoapPrivateKey &other)

详细说明

QCoapPrivateKey 用于安全地封装在 CoAP 连接协商中使用的私钥。它包含使用pre-shared 密钥和 X.509 证书进行身份验证所需的信息。

成员函数文档

QCoapPrivateKey::QCoapPrivateKey()

创建一个空的 QCoapPrivateKey 实例。

QCoapPrivateKey::QCoapPrivateKey(const Qt::HANDLE &handle)

根据本机密钥handle 构建一个QCoapPrivateKey。

QCoapPrivateKey::QCoapPrivateKey(const QByteArray &key, QSsl::KeyAlgorithm algorithm, QSsl::EncodingFormat format = QSsl::Pem, const QByteArray &passPhrase = QByteArray())

使用指定的algorithm 和编码方式format ,根据字节数组key 构建一个QCoapPrivateKey对象。

如果密钥已加密,则需要passPhrase 才能对其进行解密。

QCoapPrivateKey::QCoapPrivateKey(const QCoapPrivateKey &other)

将other 中的内容复制到该键中,使这两个键的内容完全一致。

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

通过移动构造(move-construct)创建一个 QCoapPrivateKey,使其指向与other 所指向的同一对象。

[noexcept] QCoapPrivateKey::~QCoapPrivateKey()

释放由QCoapPrivateKey 占用的任何资源。

QSsl::KeyAlgorithm QCoapPrivateKey::algorithm() const

返回密钥算法。

QSsl::EncodingFormat QCoapPrivateKey::encodingFormat() const

返回键的编码格式。

Qt::HANDLE QCoapPrivateKey::handle() const

返回指向本机键句柄的指针。

bool QCoapPrivateKey::isNull() const

如果私钥为空,则返回true ;否则返回false 。

QByteArray QCoapPrivateKey::key() const

返回经过编码的私钥。

QByteArray QCoapPrivateKey::passPhrase() const

返回该密钥的密码短语。

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

将此私钥与other 进行交换。此操作速度极快,且从不会失败。

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

将other 的内容复制到此键中,使这两个键的内容完全一致。

返回对该QCoapPrivateKey 的引用。

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