diff options
| author | Felix (xq) Queißner <git@mq32.de> | 2020-06-19 23:47:25 +0200 |
|---|---|---|
| committer | Felix (xq) Queißner <git@mq32.de> | 2020-06-19 23:47:25 +0200 |
| commit | 06d33eaa221d445561e3e76f5462a12ec4d0d7c5 (patch) | |
| tree | 2a688a3b6eae89a4e9ebd4bac24bb33c4378060b /src | |
| parent | d77e80fd9b241c6b18ebcb48d283e5419043a35e (diff) | |
| download | kristall-06d33eaa221d445561e3e76f5462a12ec4d0d7c5.tar.gz | |
Adds client certificates for HTTPS (untested)
Diffstat (limited to 'src')
| -rw-r--r-- | src/webclient.cpp | 17 | ||||
| -rw-r--r-- | src/webclient.hpp | 5 |
2 files changed, 22 insertions, 0 deletions
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<QSslCertificate> { }); + 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 diff --git a/src/webclient.hpp b/src/webclient.hpp index 53e7fad..8c3e2ba 100644 --- a/src/webclient.hpp +++ b/src/webclient.hpp @@ -24,6 +24,9 @@ public: bool cancelRequest() override; + bool enableClientCertificate(CryptoIdentity const & ident) override; + void disableClientCertificate() override; + private slots: void on_data(); void on_finished(); @@ -36,6 +39,8 @@ private: QByteArray body; RequestOptions options; + + CryptoIdentity current_identity; }; #endif // WEBCLIENT_HPP |
