WebContent+WebWorker: Use custom certificate paths with Qt networking

This change adds a `--certificate` option to both WebContent and
WebWorker, which allows one or more custom root certificate paths to be
specified. Certificates are then loaded from these paths when Qt
networking is used.

This allows WPT tests that require a https connection to be run locally
with Qt networking.
This commit is contained in:
Tim Ledbetter 2024-07-10 12:50:21 +01:00 committed by Alexander Kalenik
parent 772d64aca2
commit 28b95e8ed0
Notes: sideshowbarker 2024-07-17 01:12:07 +09:00
4 changed files with 18 additions and 6 deletions

View file

@ -5,15 +5,24 @@
*/
#include "RequestManagerQt.h"
#include "StringUtils.h"
#include "WebSocketImplQt.h"
#include "WebSocketQt.h"
#include <QNetworkCookie>
namespace Ladybird {
RequestManagerQt::RequestManagerQt()
RequestManagerQt::RequestManagerQt(Vector<ByteString> const& certificate_paths)
{
m_qnam = new QNetworkAccessManager(this);
auto ssl_configuration = QSslConfiguration::defaultConfiguration();
ssl_configuration.setPeerVerifyMode(QSslSocket::VerifyNone);
for (auto const& certificate_path : certificate_paths) {
auto certificates = QSslCertificate::fromPath(qstring_from_ak_string(certificate_path));
for (auto const& certificate : certificates)
ssl_configuration.addCaCertificate(certificate);
}
QSslConfiguration::setDefaultConfiguration(ssl_configuration);
QObject::connect(m_qnam, &QNetworkAccessManager::finished, this, &RequestManagerQt::reply_finished);
}