From 9c381ceb1fade2d1cfe9b6908860a275bad2412a Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 5 Dec 2008 09:42:06 +0000 Subject: [PATCH] Better error handling with eet identity. SVN revision: 37937 --- legacy/eet/src/bin/eet_main.c | 5 +++++ legacy/eet/src/lib/eet_cipher.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/legacy/eet/src/bin/eet_main.c b/legacy/eet/src/bin/eet_main.c index 114fffe51a..79dd490bfa 100644 --- a/legacy/eet/src/bin/eet_main.c +++ b/legacy/eet/src/bin/eet_main.c @@ -248,6 +248,11 @@ do_eet_sign(const char *file, const char *private_key, const char *public_key) } key = eet_identity_open(public_key, private_key, NULL); + if (!key) + { + fprintf(stdout, "cannot open key '%s:%s'.\n", public_key, private_key); + exit(-1); + } fprintf(stdout, "Using the following key to sign `%s`.\n", file); eet_identity_print(key, stdout); diff --git a/legacy/eet/src/lib/eet_cipher.c b/legacy/eet/src/lib/eet_cipher.c index 96949f53f6..1bd67b4add 100644 --- a/legacy/eet/src/lib/eet_cipher.c +++ b/legacy/eet/src/lib/eet_cipher.c @@ -171,7 +171,7 @@ eet_identity_open(const char *certificate_file, const char *private_key_file, Ee if (!fp) return NULL; cert = PEM_read_X509(fp, NULL, NULL, NULL); fclose(fp); - if (!cert) return NULL; + if (!cert) goto on_error; /* Check the presence of the public key. Just in case. */ pkey = X509_get_pubkey(cert);