diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-07-21 00:44:04 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-07-21 00:44:04 +0000 |
commit | 334de84cbe47944b52b004f0a7e3c4125c8b732b (patch) | |
tree | d7c23fcdec965e096178abf945214914d4c6e4c7 /src/or/connection_or.c | |
parent | 99926813b1a8b29f712f0e9ea3c8c3bfa0aba56b (diff) | |
download | tor-334de84cbe47944b52b004f0a7e3c4125c8b732b.tar.gz tor-334de84cbe47944b52b004f0a7e3c4125c8b732b.zip |
Misc small code cleanups; remove exit_server_mode(); change tor_tls_verify behavior
svn:r2073
Diffstat (limited to 'src/or/connection_or.c')
-rw-r--r-- | src/or/connection_or.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/or/connection_or.c b/src/or/connection_or.c index d60a7f53fb..860eaff4b7 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -155,10 +155,12 @@ connection_or_init_conn_from_address(connection_t *conn, connection_t *connection_or_connect(uint32_t addr, uint16_t port, const char *id_digest) { connection_t *conn; + routerinfo_t *me; tor_assert(id_digest); - if(server_mode() && 0) { /* XXX008 if I'm an OR and id_digest is my digest */ + if(server_mode() && (me=router_get_my_routerinfo()) && + !memcmp(me->identity_digest, id_digest,DIGEST_LEN)) { log_fn(LOG_WARN,"Request to connect to myself! Failing."); return NULL; } @@ -267,6 +269,7 @@ connection_tls_finish_handshake(connection_t *conn) { routerinfo_t *router; char nickname[MAX_NICKNAME_LEN+1]; connection_t *c; + crypto_pk_env_t *identity_rcvd=NULL; conn->state = OR_CONN_STATE_OPEN; connection_watch_events(conn, POLLIN); @@ -298,12 +301,18 @@ connection_tls_finish_handshake(connection_t *conn) { nickname, conn->address, conn->port); return -1; } - if(tor_tls_verify(conn->tls, router->identity_pkey)<0) { + if(tor_tls_verify(conn->tls, &identity_rcvd)<0) { log_fn(LOG_WARN,"Other side '%s' (%s:%d) has a cert but it's invalid. Closing.", nickname, conn->address, conn->port); return -1; } log_fn(LOG_DEBUG,"The router's cert is valid."); + if(crypto_pk_cmp_keys(identity_rcvd, router->identity_pkey) != 0) { + crypto_free_pk_env(identity_rcvd); + log_fn(LOG_WARN, "Identity key not as expected for %s", nickname); + return -1; + } + crypto_free_pk_env(identity_rcvd); /* XXXX008 This isn't right; fix this one we launch by identity digest * XXXX008 rather than by nickname */ |