diff ui/sslconnection.h @ 46:d28e2624c1d5

Reset connection before the next request. This makes the downloader work for the first simple test.
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 17 Mar 2014 10:51:47 +0000
parents c6125d73faf4
children 17e1c8f37d72
line wrap: on
line diff
--- a/ui/sslconnection.h	Fri Mar 14 16:40:53 2014 +0000
+++ b/ui/sslconnection.h	Mon Mar 17 10:51:47 2014 +0000
@@ -48,8 +48,12 @@
     int write(const QByteArray& request);
 
     /**
-     * @brief read at most len bytes
-     * and return them as a byte array returns a NULL byte array on error*/
+     * @brief read at most len bytes and reset the connection
+     *
+     * @param [in] len Amount of bytes to read.
+     *
+     * @returns a byte array containing the data or
+     * a NULL byte array on error*/
     QByteArray read(size_t len);
 
     bool initialized() { return mInitialized; }
@@ -70,8 +74,11 @@
     entropy_context mEntropy;
     ctr_drbg_context mCtr_drbg;
     ssl_context mSSL;
+    ssl_session mSavedSession;
     bool mInitialized;
-    bool mConnected;
+    bool mConnected; /* A connection was established */
+    bool mNeedsReset; /* The connection needs to be reset before the next
+                         write */
     int mServerFD;
     SSLConnection::ErrorCode mErrorState;
     /* @brief: Initialize polarssl structures
@@ -83,6 +90,24 @@
      * @returns: 0 on success a polarssl error otherwise.
      */
     int init();
+
+    /* @brief Reset the connection.
+     *
+     * Resets the https connection and does another handshake.
+     *
+     * @returns: 0 on success a polarssl error or -1 otherwise. */
+    int reset();
+
+    /* @brief validates that the certificate matches the pinned one.
+     *
+     * Checks the peer certificate of mSSL and validates that the
+     * certificate matches mPinnedCertificate.
+     *
+     * @returns: 0 on success a polarssl error or -1 otherwise. */
+    int validateCertificate();
+
+    /* @brief disconnects the connection */
+    void disconnect();
 };
 
 #endif

http://wald.intevation.org/projects/trustbridge/