]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
r15886@catbus: nickm | 2007-10-17 17:21:10 -0400
authorNick Mathewson <nickm@torproject.org>
Wed, 17 Oct 2007 21:26:19 +0000 (21:26 +0000)
committerNick Mathewson <nickm@torproject.org>
Wed, 17 Oct 2007 21:26:19 +0000 (21:26 +0000)
 Treat it as an error when a v3 authority cant load its keys or certificates

svn:r12004

ChangeLog
src/or/router.c

index 954b6f0ba3aa3bf5e58ba766015e9df47f296a00..c752329646ec24b6e421d9568109b6eeaf707c06 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -33,6 +33,8 @@ Changes in version 0.2.0.9-alpha - 2007-10-??
     - When we're configured to be a v3 authority, but we're only listed
       as a non-v3 authority in our DirServer line for ourself, correct the
       listing.
+    - Treat missing v3 keys or certificates as an error when running as a
+      v3 directory authority.
 
   o Minor bugfixes (v3 directory protocol)
     - Delete unverified-consensus when the real consensus is set.
index a3b61016ff01e721695a8a7ae2d4059033e53ba1..32aad5dee419e4f4d4254e324c99ea4eb9281715 100644 (file)
@@ -255,28 +255,27 @@ init_key_from_file(const char *fname, int generate, int severity)
   return NULL;
 }
 
-/** Load the v3 (voting) authority signing key and certificate from
- * <b>keydir</b>, if they are present. */
+/** Load the v3 (voting) authority signing key and certificate, if they are
+ * present.  Return -1 if anything is missing, mismatched, or unloadable;
+ * return 0 on success. */
 /* XXXX020 maybe move to dirserv.c or dirvote.c */
-static void
-init_v3_authority_keys(const char *keydir)
+static int
+init_v3_authority_keys(void)
 {
   char *fname = NULL, *cert = NULL;
   const char *eos = NULL;
-  size_t fname_len = strlen(keydir) + 64;
   crypto_pk_env_t *signing_key = NULL;
   authority_cert_t *parsed = NULL;
+  int r = -1;
 
-  fname = tor_malloc(fname_len);
-  tor_snprintf(fname, fname_len, "%s"PATH_SEPARATOR"authority_signing_key",
-               keydir);
+  fname = get_datadir_fname2("keys", "authority_signing_key");
   signing_key = init_key_from_file(fname, 0, LOG_INFO);
   if (!signing_key) {
     log_warn(LD_DIR, "No version 3 directory key found in %s", fname);
     goto done;
   }
-  tor_snprintf(fname, fname_len, "%s"PATH_SEPARATOR"authority_certificate",
-               keydir);
+  tor_free(fname);
+  fname = get_datadir_fname2("keys", "authority_certificate");
   cert = read_file_to_str(fname, 0, NULL);
   if (!cert) {
     log_warn(LD_DIR, "Signing key found, but no certificate found in %s",
@@ -308,6 +307,7 @@ init_v3_authority_keys(const char *keydir)
   parsed = NULL;
   signing_key = NULL;
 
+  r = 0;
  done:
   tor_free(fname);
   tor_free(cert);
@@ -315,6 +315,7 @@ init_v3_authority_keys(const char *keydir)
     crypto_free_pk_env(signing_key);
   if (parsed)
     authority_cert_free(parsed);
+  return r;
 }
 
 /** If we're a v3 authority, check whether we have a certificatge that's
@@ -420,7 +421,12 @@ init_keys(void)
   /* 1a. Read v3 directory authority key/cert information. */
   memset(v3_digest, 0, sizeof(v3_digest));
   if (authdir_mode_v3(options)) {
-    init_v3_authority_keys(keydir);
+    if (init_v3_authority_keys()<0) {
+      log_err(LD_GENERAL, "We're configured as a V3 authority, but we "
+              "were unable to load our v3 authority keys and certificate! "
+              "Use tor-gencert to generate them. Dying.");
+      return -1;
+    }
     if (get_my_v3_authority_cert()) {
       crypto_pk_get_digest(get_my_v3_authority_cert()->identity_key,
                            v3_digest);