--- curl-7.15.4-20060507/lib/ssluse.c	2006-05-05 23:00:17.000000000 -0300
+++ curl-7.15.4-20060507-patched/lib/ssluse.c	2006-05-09 01:26:47.000000000 -0300
@@ -1168,6 +1168,8 @@
     break;
   }
 
+  if (connssl->ctx)
+    SSL_CTX_free(connssl->ctx);
   connssl->ctx = SSL_CTX_new(req_method);
 
   if(!connssl->ctx) {
@@ -1279,6 +1281,8 @@
   }
 
   /* Lets make an SSL structure */
+  if (connssl->handle)
+    SSL_free(connssl->handle);
   connssl->handle = SSL_new(connssl->ctx);
   if (!connssl->handle) {
     failf(data, "SSL: couldn't create a context (handle)!");
@@ -1638,6 +1642,9 @@
     *done = FALSE;
   }
 
+  // Reset our state machine
+  connssl->connecting_state = ssl_connect_1;
+
   return CURLE_OK;
 }
 

