ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/conf.C
(Generate patch)

Comparing gvpe/src/conf.C (file contents):
Revision 1.21 by pcg, Sat Jan 17 01:18:36 2004 UTC vs.
Revision 1.22 by pcg, Thu Jan 29 18:55:10 2004 UTC

33 33
34#include <openssl/err.h> 34#include <openssl/err.h>
35#include <openssl/pem.h> 35#include <openssl/pem.h>
36#include <openssl/rsa.h> 36#include <openssl/rsa.h>
37#include <openssl/rand.h> 37#include <openssl/rand.h>
38#include <openssl/bn.h>
38 39
39#include "gettext.h" 40#include "gettext.h"
40 41
41#include "conf.h" 42#include "conf.h"
42#include "slog.h" 43#include "slog.h"
258 259
259 if (!PEM_read_RSAPublicKey(f, &node->rsa_key, NULL, NULL)) 260 if (!PEM_read_RSAPublicKey(f, &node->rsa_key, NULL, NULL))
260 { 261 {
261 ERR_load_RSA_strings (); ERR_load_PEM_strings (); 262 ERR_load_RSA_strings (); ERR_load_PEM_strings ();
262 slog (L_ERR, _("unable to open public rsa key file '%s': %s"), fname, ERR_error_string (ERR_get_error (), 0)); 263 slog (L_ERR, _("unable to open public rsa key file '%s': %s"), fname, ERR_error_string (ERR_get_error (), 0));
263 exit (1); 264 exit (EXIT_FAILURE);
264 } 265 }
265 266
266 RSA_blinding_on (node->rsa_key, 0); 267 require (RSA_blinding_on (node->rsa_key, 0));
267 268
268 fclose (f); 269 fclose (f);
269 } 270 }
270 else 271 else
271 { 272 {
272 slog (need_keys ? L_ERR : L_NOTICE, _("unable to read public rsa key file '%s': %s"), fname, strerror (errno)); 273 slog (need_keys ? L_ERR : L_NOTICE, _("unable to read public rsa key file '%s': %s"), fname, strerror (errno));
273 274
274 if (need_keys) 275 if (need_keys)
275 exit (1); 276 exit (EXIT_FAILURE);
276 } 277 }
277 278
278 free (fname); 279 free (fname);
279 } 280 }
280 281
389 fclose (f); 390 fclose (f);
390 } 391 }
391 else 392 else
392 { 393 {
393 slog (L_ERR, _("unable to read config file '%s': %s"), fname, strerror (errno)); 394 slog (L_ERR, _("unable to read config file '%s': %s"), fname, strerror (errno));
394 exit (1); 395 exit (EXIT_FAILURE);
395 } 396 }
396 397
397 free (fname); 398 free (fname);
398 399
399 fname = config_filename (prikeyfile, "hostkey"); 400 fname = config_filename (prikeyfile, "hostkey");
405 406
406 if (!PEM_read_RSAPrivateKey (f, &rsa_key, NULL, NULL)) 407 if (!PEM_read_RSAPrivateKey (f, &rsa_key, NULL, NULL))
407 { 408 {
408 ERR_load_RSA_strings (); ERR_load_PEM_strings (); 409 ERR_load_RSA_strings (); ERR_load_PEM_strings ();
409 slog (L_ERR, _("unable to read private rsa key file '%s': %s"), fname, ERR_error_string (ERR_get_error (), 0)); 410 slog (L_ERR, _("unable to read private rsa key file '%s': %s"), fname, ERR_error_string (ERR_get_error (), 0));
410 exit (1); 411 exit (EXIT_FAILURE);
411 } 412 }
412 413
413 RSA_blinding_on (rsa_key, 0); 414 require (RSA_blinding_on (rsa_key, 0));
414 415
415 fclose (f); 416 fclose (f);
416 } 417 }
417 else 418 else
418 { 419 {
419 slog (need_keys ? L_ERR : L_NOTICE, _("unable to open private rsa key file '%s': %s"), fname, strerror (errno)); 420 slog (need_keys ? L_ERR : L_NOTICE, _("unable to open private rsa key file '%s': %s"), fname, strerror (errno));
420 421
421 if (need_keys) 422 if (need_keys)
422 exit (1); 423 exit (EXIT_FAILURE);
423 } 424 }
425
426 if (need_keys && rsa_key && thisnode && thisnode->rsa_key)
427 if (BN_cmp (rsa_key->n, thisnode->rsa_key->n) != 0
428 || BN_cmp (rsa_key->e, thisnode->rsa_key->e) != 0)
429 {
430 slog (L_NOTICE, _("private hostkey and public node key mismatch: is '%s' the correct node?"), ::thisnode);
431 exit (EXIT_FAILURE);
432 }
424 433
425 free (fname); 434 free (fname);
426} 435}
427 436
428char *configuration::config_filename (const char *name, const char *dflt) 437char *configuration::config_filename (const char *name, const char *dflt)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines