From 06d33eaa221d445561e3e76f5462a12ec4d0d7c5 Mon Sep 17 00:00:00 2001 From: "Felix (xq) Queißner" Date: Fri, 19 Jun 2020 23:47:25 +0200 Subject: Adds client certificates for HTTPS (untested) --- src/webclient.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/webclient.cpp') diff --git a/src/webclient.cpp b/src/webclient.cpp index b5d4d9d..b50d508 100644 --- a/src/webclient.cpp +++ b/src/webclient.cpp @@ -41,6 +41,11 @@ bool WebClient::startRequest(const QUrl &url, RequestOptions options) else ssl_config.setCaCertificates(QList { }); + if(this->current_identity.isValid()) { + ssl_config.setLocalCertificate(this->current_identity.certificate); + ssl_config.setPrivateKey(this->current_identity.private_key); + } + // request.setMaximumRedirectsAllowed(5); request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, false); request.setSslConfiguration(ssl_config); @@ -73,6 +78,17 @@ bool WebClient::cancelRequest() return true; } +bool WebClient::enableClientCertificate(const CryptoIdentity &ident) +{ + current_identity = ident; + return true; +} + +void WebClient::disableClientCertificate() +{ + current_identity = CryptoIdentity(); +} + void WebClient::on_data() { this->body.append(this->current_reply->readAll()); @@ -112,6 +128,7 @@ void WebClient::on_finished() } qDebug() << "web network error" << reply->errorString(); + qDebug() << this->body; emit this->networkError(error, reply->errorString()); } else -- cgit v1.2.3