QWebEngineClientCertificateStore Class

QWebEngineClientCertificateStore 类为客户端证书提供了一个内存存储空间。更多

Header: #include <QWebEngineClientCertificateStore>
CMake: find_package(Qt6 REQUIRED COMPONENTS WebEngineCore)
target_link_libraries(mytarget PRIVATE Qt6::WebEngineCore)
qmake: QT += webenginecore

公共函数

void add(const QSslCertificate &certificate, const QSslKey &privateKey)
QList<QSslCertificate> certificates() const
void clear()
void remove(const QSslCertificate &certificate)

详细说明

该类允许在内存中存储客户端证书。当网站请求 SSL 客户端证书时,QWebEnginePage::selectClientCertificate 信号将与本地证书存储区或内存存储区中的匹配证书一起发出。

该类实例可通过QWebEngineProfile::clientCertificateStore() 方法获取。

QFile certFile(":/resouces/certificate.crt");
certFile.open(QIODevice::ReadOnly);
const QSslCertificate cert(certFile.readAll(), QSsl::Pem);

QFile keyFile(":/resources/privatekey.key");
keyFile.open(QIODevice::ReadOnly);
const QSslKey sslKey(keyFile.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, "");

QWebEngineProfile profile;
profile.clientCertificateStore()->add(cert, sslKey);

成员函数文档

void QWebEngineClientCertificateStore::add(const QSslCertificate &certificate, const QSslKey &privateKey)

将带有privateKeycertificate 添加到内存客户端证书存储中。

QList<QSslCertificate> QWebEngineClientCertificateStore::certificates() const

返回内存存储中的客户证书列表。如果存储中不包含任何证书,则返回空列表。

void QWebEngineClientCertificateStore::clear()

清除内存存储中的所有客户证书。

void QWebEngineClientCertificateStore::remove(const QSslCertificate &certificate)

删除内存客户证书存储中与证书certificate 匹配的所有客户证书实例。

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