diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2014-11-07 11:13:12 +0100 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2015-01-23 14:27:25 +0100 |
commit | 0192630f55bb62bd7cf3a1dc29c6c0624ca7759c (patch) | |
tree | 0f393f763adcc038241f9f1200c4ae99b8fa0a4c /src/network/access/qnetworkaccessmanager.cpp | |
parent | c27e1f498f933406aebc1334482da6761fe6de8c (diff) |
QNetworkAccessManager: introduce support for TLS PSK
Expose the same kind of TLS PSK client support we already have set
in place for QSslSocket.
[ChangeLog][QtNetwork][QNetworkAccessManager] It is now possible to use
TLS PSK ciphersuites when using HTTPS (or similar protocols working over
SSL).
Change-Id: I56a048e9f4f841f886758c781af2867d18538a3e
Reviewed-by: Richard J. Moore <rich@kde.org>
Diffstat (limited to 'src/network/access/qnetworkaccessmanager.cpp')
-rw-r--r-- | src/network/access/qnetworkaccessmanager.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 52d56fb071..c661854a3a 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -416,6 +416,29 @@ static void ensureInitialized() QNetworkReply::sslConfiguration(), QNetworkReply::ignoreSslErrors() */ +/*! + \fn void QNetworkAccessManager::preSharedKeyAuthenticationRequired(QNetworkReply *reply, QSslPreSharedKeyAuthenticator *authenticator) + \since 5.5 + + This signal is emitted if the SSL/TLS handshake negotiates a PSK + ciphersuite, and therefore a PSK authentication is then required. + The \a reply object is the QNetworkReply that is negotiating + such ciphersuites. + + When using PSK, the client must send to the server a valid identity and a + valid pre shared key, in order for the SSL handshake to continue. + Applications can provide this information in a slot connected to this + signal, by filling in the passed \a authenticator object according to their + needs. + + \note Ignoring this signal, or failing to provide the required credentials, + will cause the handshake to fail, and therefore the connection to be aborted. + + \note The \a authenticator object is owned by the reply and must not be + deleted by the application. + + \sa QSslPreSharedKeyAuthenticator +*/ /*! Constructs a QNetworkAccessManager object that is the center of @@ -434,6 +457,7 @@ QNetworkAccessManager::QNetworkAccessManager(QObject *parent) #ifndef QT_NO_SSL qRegisterMetaType<QList<QSslError> >(); qRegisterMetaType<QSslConfiguration>(); + qRegisterMetaType<QSslPreSharedKeyAuthenticator *>(); #endif qRegisterMetaType<QList<QPair<QByteArray,QByteArray> > >(); #ifndef QT_NO_HTTP @@ -1328,6 +1352,18 @@ void QNetworkAccessManagerPrivate::_q_replySslErrors(const QList<QSslError> &err #endif } +void QNetworkAccessManagerPrivate::_q_replyPreSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *authenticator) +{ +#ifndef QT_NO_SSL + Q_Q(QNetworkAccessManager); + QNetworkReply *reply = qobject_cast<QNetworkReply *>(q->sender()); + if (reply) + emit q->preSharedKeyAuthenticationRequired(reply, authenticator); +#else + Q_UNUSED(authenticator); +#endif +} + QNetworkReply *QNetworkAccessManagerPrivate::postProcess(QNetworkReply *reply) { Q_Q(QNetworkAccessManager); @@ -1338,6 +1374,7 @@ QNetworkReply *QNetworkAccessManagerPrivate::postProcess(QNetworkReply *reply) * avoid getting a connection error. */ q->connect(reply, SIGNAL(encrypted()), SLOT(_q_replyEncrypted())); q->connect(reply, SIGNAL(sslErrors(QList<QSslError>)), SLOT(_q_replySslErrors(QList<QSslError>))); + q->connect(reply, SIGNAL(preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*)), SLOT(_q_replyPreSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*))); #endif #ifndef QT_NO_BEARERMANAGEMENT activeReplyCount++; |