walters / rpms / openssl

Forked from rpms/openssl 6 years ago
Clone
0fd0958
From 5bb6d96558ff6013826e3362f4c81513e3df23ff Mon Sep 17 00:00:00 2001
0fd0958
From: Ben Laurie <ben@openssl.org>
0fd0958
Date: Thu, 13 Dec 2012 15:48:42 +0000
0fd0958
Subject: [PATCH] Make verify return errors.
0fd0958
0fd0958
---
0fd0958
 CHANGES       |    3 +++
0fd0958
 Makefile.org  |    2 +-
0fd0958
 apps/verify.c |   16 ++++++++++++----
0fd0958
 test/Makefile |    2 +-
0fd0958
 4 files changed, 17 insertions(+), 6 deletions(-)
0fd0958
0fd0958
diff --git a/Makefile.org b/Makefile.org
0fd0958
index 55273ea..43d16cb 100644
0fd0958
--- a/Makefile.org
0fd0958
+++ b/Makefile.org
0fd0958
@@ -444,7 +444,7 @@ rehash.time: certs apps
0fd0958
 		[ -x "apps/openssl.exe" ] && OPENSSL="apps/openssl.exe" || :; \
0fd0958
 		OPENSSL_DEBUG_MEMORY=on; \
0fd0958
 		export OPENSSL OPENSSL_DEBUG_MEMORY; \
0fd0958
-		$(PERL) tools/c_rehash certs) && \
0fd0958
+		$(PERL) tools/c_rehash certs/demo) && \
0fd0958
 		touch rehash.time; \
0fd0958
 	else :; fi
0fd0958
 
0fd0958
diff --git a/apps/verify.c b/apps/verify.c
0fd0958
index 0f34b86..893670f 100644
0fd0958
--- a/apps/verify.c
0fd0958
+++ b/apps/verify.c
0fd0958
@@ -222,11 +222,19 @@ int MAIN(int argc, char **argv)
0fd0958
 			goto end;
0fd0958
 		}
0fd0958
 
0fd0958
-	if (argc < 1) check(cert_ctx, NULL, untrusted, trusted, crls, e);
0fd0958
+	ret = 0;
0fd0958
+	if (argc < 1)
0fd0958
+		{ 
0fd0958
+		if (1 != check(cert_ctx, NULL, untrusted, trusted, crls, e))
0fd0958
+			ret = -1;
0fd0958
+		}
0fd0958
 	else
0fd0958
+		{
0fd0958
 		for (i=0; i
0fd0958
-			check(cert_ctx,argv[i], untrusted, trusted, crls, e);
0fd0958
-	ret=0;
0fd0958
+			if (1 != check(cert_ctx,argv[i], untrusted, trusted, crls, e))
0fd0958
+				ret = -1;
0fd0958
+		}
0fd0958
+
0fd0958
 end:
0fd0958
 	if (ret == 1) {
0fd0958
 		BIO_printf(bio_err,"usage: verify [-verbose] [-CApath path] [-CAfile file] [-purpose purpose] [-crl_check]");
0fd0958
@@ -252,7 +260,7 @@ end:
0fd0958
 	sk_X509_pop_free(trusted, X509_free);
0fd0958
 	sk_X509_CRL_pop_free(crls, X509_CRL_free);
0fd0958
 	apps_shutdown();
0fd0958
-	OPENSSL_EXIT(ret);
0fd0958
+	OPENSSL_EXIT(ret < 0 ? 2 : ret);
0fd0958
 	}
0fd0958
 
0fd0958
 static int check(X509_STORE *ctx, char *file,
0fd0958
diff --git a/test/Makefile b/test/Makefile
0fd0958
index 09e6848..4c9eabc 100644
0fd0958
--- a/test/Makefile
0fd0958
+++ b/test/Makefile
0fd0958
@@ -246,7 +246,7 @@ test_ecdh:
0fd0958
 test_verify:
0fd0958
 	@echo "The following command should have some OK's and some failures"
0fd0958
 	@echo "There are definitly a few expired certificates"
0fd0958
-	../util/shlib_wrap.sh ../apps/openssl verify -CApath ../certs ../certs/*.pem
0fd0958
+	../util/shlib_wrap.sh ../apps/openssl verify -CApath ../certs/demo ../certs/demo/*.pem
0fd0958
 
0fd0958
 test_dh:
0fd0958
 	@echo "Generate a set of DH parameters"
0fd0958
-- 
0fd0958
1.7.7.6
0fd0958