]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
changed semantics of the GNUTLS_E_REHANDSHAKE error code.
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Mon, 5 Nov 2001 20:14:57 +0000 (20:14 +0000)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Mon, 5 Nov 2001 20:14:57 +0000 (20:14 +0000)
NEWS
lib/gnutls_handshake.c
lib/gnutls_record.c
src/cli.c

diff --git a/NEWS b/NEWS
index 18ea7b03dc69ecb90808ca9c676f2ab7cd53e0c0..90432a4fab8228a829cc90c5cf45c50892fafcf6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,8 @@
+Version 0.2.11
+-  Changed the meaning of GNUTLS_E_REHANDSHAKE value. If this value
+  is returned, then the caller should perform a handshake or send
+  an alert to the peer.
+
 Version 0.2.10 (5/11/2001)
 - Corrected bugs and improved non blocking IO
 - Added hooks to use external database to store sessions
index c8eac441d80034a3f9b3755962e7f7ec6f3d6b55..2b367bc67fe73dac74fb27aa79f4b7ebacaf0aa0 100644 (file)
@@ -1807,7 +1807,7 @@ int _gnutls_recv_hello_request(SOCKET cd, GNUTLS_STATE state, void *data,
        }
        return 0;
 
-#else                          /* this does not seem to work - yet */
+#else  /* this does seem to work - now */
        uint8 type;
 
        if (state->security_parameters.entity == GNUTLS_SERVER) {
@@ -1820,7 +1820,7 @@ int _gnutls_recv_hello_request(SOCKET cd, GNUTLS_STATE state, void *data,
        }
        type = ((uint8 *) data)[0];
        if (type == GNUTLS_HELLO_REQUEST)
-               return gnutls_handshake(cd, state);
+               return GNUTLS_E_REHANDSHAKE;
        else {
                gnutls_assert();
                return GNUTLS_E_UNEXPECTED_PACKET;
index b17fec6b1fd8843625fa26c912fd4a6a1dfb0632..2ede69d25348eefce433c661bbccd88860226da4 100644 (file)
@@ -899,10 +899,6 @@ ssize_t gnutls_recv_int(SOCKET cd, GNUTLS_STATE state, ContentType type, Handsha
                if (recv_type == GNUTLS_HANDSHAKE) {
                        /* we may get a hello request */
                        ret = _gnutls_recv_hello_request( cd, state, tmpdata, tmplen);
-                       if (ret < 0) {
-                               gnutls_assert();
-                       } else /* inform the caller */
-                               ret = GNUTLS_E_REHANDSHAKE;
                } else {
                        gnutls_assert();
                        ret = GNUTLS_E_UNEXPECTED_PACKET; 
@@ -1078,6 +1074,11 @@ ssize_t gnutls_write(SOCKET cd, GNUTLS_STATE state, const void *data, size_t siz
   * difference is that is accepts a GNUTLS state. 
   * Returns the number of bytes received, zero on EOF, or
   * a negative error code.
+  *
+  * If this function returns GNUTLS_E_REHANDSHAKE, then you must
+  * either send an alert containing NO_RENEGOTIATION, or perform a
+  * handshake. (only a client may receive this message)
+  *
   **/
 ssize_t gnutls_read(SOCKET cd, GNUTLS_STATE state, void *data, size_t sizeofdata) {
        return gnutls_recv_int( cd, state, GNUTLS_APPLICATION_DATA, -1, data, sizeofdata);
index 0b06a4518141dc2d9a453c665cfc9acf90dd31b8..1e94b599a1dac8d525ab46ce0f0db45d22ca6754 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -348,9 +348,15 @@ int main(int argc, char** argv)
                        } else {
                                if (ret==GNUTLS_E_WARNING_ALERT_RECEIVED || ret==GNUTLS_E_FATAL_ALERT_RECEIVED)
                                        printf("* Received alert [%d]\n", gnutls_get_last_alert(state));
-                               if (ret==GNUTLS_E_REHANDSHAKE)
-                                       printf("* Rehandshake was performed\n");
-
+                               if (ret==GNUTLS_E_REHANDSHAKE) {
+                                       do {
+                                               ret = gnutls_handshake( sd, state);
+                                       } while( ret==GNUTLS_E_AGAIN || ret==GNUTLS_E_INTERRUPTED);
+                                       if (ret==0) printf("* Rehandshake was performed\n");
+                                       else {
+                                               printf("* Rehandshake Failed [%d]\n", ret);
+                                       }
+                               }
                                if (ret > 0) {
                                        printf("- Received[%d]: ", ret);
                                        for (ii=0;ii<ret;ii++) {