aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-12-01 08:09:48 +0000
committerNick Mathewson <nickm@torproject.org>2007-12-01 08:09:48 +0000
commitd8ad247dfdea0705de2990af68026cdf6da22430 (patch)
tree91be989c484e6ae0857cfe08f4e295a919921771 /src/common
parent1789f94668f8da029d18efb51bc3d0652488f706 (diff)
downloadtor-d8ad247dfdea0705de2990af68026cdf6da22430.tar
tor-d8ad247dfdea0705de2990af68026cdf6da22430.tar.gz
r15088@tombo: nickm | 2007-11-30 23:47:29 -0500
Add support to get a callback invoked when the client renegotiate a connection. Also, make clients renegotiate. (not enabled yet, until they detect that the server acted like a v2 server) svn:r12623
Diffstat (limited to 'src/common')
-rw-r--r--src/common/tortls.c16
-rw-r--r--src/common/tortls.h3
2 files changed, 18 insertions, 1 deletions
diff --git a/src/common/tortls.c b/src/common/tortls.c
index 8949c3b0d..8c2ee932a 100644
--- a/src/common/tortls.c
+++ b/src/common/tortls.c
@@ -70,6 +70,8 @@ struct tor_tls_t {
* time. */
unsigned long last_write_count;
unsigned long last_read_count;
+ void (*negotiated_callback)(tor_tls_t *tls, void *arg);
+ void *callback_arg;
};
static void tor_tls_context_decref(tor_tls_context_t *ctx);
@@ -606,6 +608,16 @@ tor_tls_new(int sock, int isServer)
return result;
}
+/**DOCDOC*/
+void
+tor_tls_set_renegotiate_callback(tor_tls_t *tls,
+ void (*cb)(tor_tls_t *, void *arg),
+ void *arg)
+{
+ tls->negotiated_callback = cb;
+ tls->callback_arg = arg;
+}
+
/** Return whether this tls initiated the connect (client) or
* received it (server). */
int
@@ -624,6 +636,7 @@ tor_tls_free(tor_tls_t *tls)
tor_assert(tls && tls->ssl);
SSL_free(tls->ssl);
tls->ssl = NULL;
+ tls->negotiated_callback = NULL;
if (tls->context)
tor_tls_context_decref(tls->context);
tor_free(tls);
@@ -648,7 +661,8 @@ tor_tls_read(tor_tls_t *tls, char *cp, size_t len)
tls->hadCert = 1;
/* New certificate! */
log_info(LD_NET, "Got a TLS renegotiation.");
- /* XXXX020 call some kind of 'there was a renegotiation' callback. */
+ if (tls->negotiated_callback)
+ tls->negotiated_callback(tls, tls->callback_arg);
}
#endif
return r;
diff --git a/src/common/tortls.h b/src/common/tortls.h
index c8155de2f..fe18f3787 100644
--- a/src/common/tortls.h
+++ b/src/common/tortls.h
@@ -52,6 +52,9 @@ void tor_tls_free_all(void);
int tor_tls_context_new(crypto_pk_env_t *rsa,
const char *nickname, unsigned int key_lifetime);
tor_tls_t *tor_tls_new(int sock, int is_server);
+void tor_tls_set_renegotiate_callback(tor_tls_t *tls,
+ void (*cb)(tor_tls_t *, void *arg),
+ void *arg);
int tor_tls_is_server(tor_tls_t *tls);
void tor_tls_free(tor_tls_t *tls);
int tor_tls_peer_has_cert(tor_tls_t *tls);