Skip to content
Browse files

QxtWebRequestEvent: add SSL and certificate status

  • Loading branch information...
1 parent 7e29b30 commit 8869b4d8b204cbb37ee71572c3a531eb16683aea ahigerd committed Mar 1, 2011
Showing with 38 additions and 2 deletions.
  1. +10 −0 src/web/qxthttpsessionmanager.cpp
  2. +21 −2 src/web/qxtwebevent.cpp
  3. +7 −0 src/web/qxtwebevent.h
View
10 src/web/qxthttpsessionmanager.cpp
@@ -62,6 +62,9 @@ posting events. It is reentrant for all other functionality.
#include <QThread>
#include <qxtmetaobject.h>
#include <QTcpSocket>
+#ifndef QT_NO_OPENSSL
+#include <QSslSocket>
+#endif
#ifndef QXT_DOXYGEN_RUN
class QxtHttpSessionManagerPrivate : public QxtPrivate<QxtHttpSessionManager>
@@ -366,6 +369,13 @@ void QxtHttpSessionManager::incomingRequest(quint32 requestID, const QHttpReques
if (socket)
{
event->remoteAddress = socket->peerAddress().toString();
+#ifndef QT_NO_OPENSSL
+ QSslSocket* sslSocket = qobject_cast<QSslSocket*>(socket);
+ if(sslSocket) {
+ event->isSecure = true;
+ event->clientCertificate = sslSocket->peerCertificate();
+ }
+#endif
}
event->method = header.method();
event->cookies = cookies;
View
23 src/web/qxtwebevent.cpp
@@ -90,7 +90,7 @@ browser.
* Constructs a QxtWebRequestEvent for the specified \a sessionID, \a requestID and \a url.
*/
QxtWebRequestEvent::QxtWebRequestEvent(int sessionID, int requestID, const QUrl& url)
- : QxtWebEvent(QxtWebEvent::Request, sessionID), requestID(requestID), url(url), originalUrl(url) {}
+ : QxtWebEvent(QxtWebEvent::Request, sessionID), requestID(requestID), url(url), originalUrl(url), isSecure(false) {}
/*!
* Destroys the event and any content that may still be associated with it.
@@ -129,6 +129,25 @@ QxtWebRequestEvent::~QxtWebRequestEvent()
*/
/*!
+ * \variable QxtWebRequestEvent::isSecure
+ * If the request was sent over an encrypted channel, such as HTTPS, isSecure will be
+ * set to \a true and clientCertificate will be set. Otherwise, isSecure will be set
+ * to \a false.
+ *
+ * \sa clientCertificate
+ */
+
+/*!
+ * \variable QxtWebRequest::clientCertificate
+ * If the request was sent over an encrypted channel, such as HTTPS, clientCertificate
+ * will contain the certificate presented by the requesting client, if any.
+ *
+ * This member variable is not available if Qt was not compiled with SSL support.
+ *
+ * \sa isSecure
+ */
+
+/*!
* \variable QxtWebRequestEvent::cookies
* Contains all of the cookies sent by the web browser.
*/
@@ -137,7 +156,7 @@ QxtWebRequestEvent::~QxtWebRequestEvent()
* \variable QxtWebRequestEvent::headers
* Contains all of the headers sent by the web browser.
*
- * Note that use of these values may not be portable across session maangers.
+ * Note that use of these values may not be portable across session managers.
*/
/*
View
7 src/web/qxtwebevent.h
@@ -34,6 +34,9 @@
#include <QUrl>
#include <QMultiHash>
#include <QDateTime>
+#ifndef QT_NO_OPENSSL
+#include <QSslCertificate>
+#endif
QT_FORWARD_DECLARE_CLASS(QIODevice)
class QxtWebContent;
@@ -78,6 +81,10 @@ class QXT_WEB_EXPORT QxtWebRequestEvent : public QxtWebEvent
QPointer<QxtWebContent> content;
QString method;
QString remoteAddress;
+ bool isSecure;
+#ifndef QT_NO_OPENSSL
+ QSslCertificate clientCertificate;
+#endif
QMultiHash<QString, QString> cookies;
QMultiHash<QString, QString> headers;

0 comments on commit 8869b4d

Please sign in to comment.
Something went wrong with that request. Please try again.