diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-03-18 11:48:21 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-03-18 11:48:21 +0000 |
commit | 651ce7813c3726accadc0bf54952ed8a7d22407d (patch) | |
tree | 651a9d045bc6bfb632d749499875ecc111f9a821 /src/util/crypto_rsa.c | |
parent | 24c7345ea01a015a00a711e91eb893c5c1018abc (diff) |
fix
Diffstat (limited to 'src/util/crypto_rsa.c')
-rw-r--r-- | src/util/crypto_rsa.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c index df4e24e7c5..4a0a66b0ab 100644 --- a/src/util/crypto_rsa.c +++ b/src/util/crypto_rsa.c @@ -713,8 +713,14 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ - ("File `%s' does not contain a valid private key. You should delete it.\n"), + ("File `%s' does not contain a valid private key. Deleting it.\n"), filename); + if (0 != UNLINK (filename)) + { + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, + "unlink", + filename); + } } GNUNET_free (enc); if (GNUNET_YES != @@ -722,12 +728,15 @@ GNUNET_CRYPTO_rsa_key_create_from_file (const char *filename) sizeof (struct RsaPrivateKeyBinaryEncoded))) GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename); GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd)); - GNUNET_CRYPTO_rsa_key_get_public (ret, &pub); - GNUNET_CRYPTO_hash (&pub, sizeof (pub), &pid.hashPubKey); - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - _("I am host `%s'. Read private key from `%s'.\n"), - GNUNET_i2s (&pid), - filename); + if (ret != NULL) + { + GNUNET_CRYPTO_rsa_key_get_public (ret, &pub); + GNUNET_CRYPTO_hash (&pub, sizeof (pub), &pid.hashPubKey); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, + _("I am host `%s'. Read private key from `%s'.\n"), + GNUNET_i2s (&pid), + filename); + } return ret; } |