[or-cvs] Example code to get nickname from cert

Nick Mathewson nickm at seul.org
Sun Oct 19 00:47:05 UTC 2003


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv10766/or

Modified Files:
	connection_or.c 
Log Message:
Example code to get nickname from cert

Index: connection_or.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_or.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- connection_or.c	15 Oct 2003 18:48:48 -0000	1.69
+++ connection_or.c	19 Oct 2003 00:47:03 -0000	1.70
@@ -180,6 +180,7 @@
 static int connection_tls_finish_handshake(connection_t *conn) {
   crypto_pk_env_t *pk;
   routerinfo_t *router;
+  char nickname[255];
 
   conn->state = OR_CONN_STATE_OPEN;
   directory_set_dirty();
@@ -187,6 +188,12 @@
   log_fn(LOG_DEBUG,"tls handshake done. verifying.");
   if(options.OnionRouter) { /* I'm an OR */
     if(tor_tls_peer_has_cert(conn->tls)) { /* it's another OR */
+      if (tor_tls_get_peer_cert_nickname(conn->tls, nickname, 256)) {
+        log_fn(LOG_WARN,"Other side (%s:%d) has a cert without a valid nickname. Closing.",
+               conn->address, conn->port);
+        return -1;
+      }
+      log_fn(LOG_DEBUG,"Other side claims to be \"%s\"",nickname);
       pk = tor_tls_verify(conn->tls);
       if(!pk) {
         log_fn(LOG_WARN,"Other side (%s:%d) has a cert but it's invalid. Closing.",



More information about the tor-commits mailing list