diff options
author | Richard Levitte <levitte@openssl.org> | 2001-06-25 14:23:36 +0000 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2001-06-25 14:23:36 +0000 |
commit | 7953b8ff1b1a60c50fa56543b78d37bd0ca66490 (patch) | |
tree | 5517ba35fbec607ea26feea6ab4958e1c6958fcd /apps/verify.c | |
parent | b1460627f30ac4a315b87c5b00b8363b11bcf673 (diff) |
Make better use of load_cert, load_certs and load_key.
Diffstat (limited to 'apps/verify.c')
-rw-r--r-- | apps/verify.c | 36 |
1 files changed, 6 insertions, 30 deletions
diff --git a/apps/verify.c b/apps/verify.c index d5f07c2db4..60da5c5a24 100644 --- a/apps/verify.c +++ b/apps/verify.c @@ -71,7 +71,7 @@ #define PROG verify_main static int MS_CALLBACK cb(int ok, X509_STORE_CTX *ctx); -static int check(X509_STORE *ctx, char *file, STACK_OF(X509) *uchain, STACK_OF(X509) *tchain, int purpose); +static int check(X509_STORE *ctx, char *file, STACK_OF(X509) *uchain, STACK_OF(X509) *tchain, int purpose, ENGINE *e); static STACK_OF(X509) *load_untrusted(char *file); static int v_verbose=0, vflags = 0; @@ -208,10 +208,10 @@ int MAIN(int argc, char **argv) } } - if (argc < 1) check(cert_ctx, NULL, untrusted, trusted, purpose); + if (argc < 1) check(cert_ctx, NULL, untrusted, trusted, purpose, e); else for (i=0; i<argc; i++) - check(cert_ctx,argv[i], untrusted, trusted, purpose); + check(cert_ctx,argv[i], untrusted, trusted, purpose, e); ret=0; end: if (ret == 1) { @@ -227,42 +227,19 @@ end: if (cert_ctx != NULL) X509_STORE_free(cert_ctx); sk_X509_pop_free(untrusted, X509_free); sk_X509_pop_free(trusted, X509_free); + apps_shutdown(); EXIT(ret); } -static int check(X509_STORE *ctx, char *file, STACK_OF(X509) *uchain, STACK_OF(X509) *tchain, int purpose) +static int check(X509_STORE *ctx, char *file, STACK_OF(X509) *uchain, STACK_OF(X509) *tchain, int purpose, ENGINE *e) { X509 *x=NULL; - BIO *in=NULL; int i=0,ret=0; X509_STORE_CTX *csc; - in=BIO_new(BIO_s_file()); - if (in == NULL) - { - ERR_print_errors(bio_err); - goto end; - } - - if (file == NULL) - BIO_set_fp(in,stdin,BIO_NOCLOSE); - else - { - if (BIO_read_filename(in,file) <= 0) - { - perror(file); - goto end; - } - } - - x=PEM_read_bio_X509(in,NULL,NULL,NULL); + x = load_cert(bio_err, file, FORMAT_PEM, NULL, e, "certificate file"); if (x == NULL) - { - fprintf(stdout,"%s: unable to load certificate file\n", - (file == NULL)?"stdin":file); - ERR_print_errors(bio_err); goto end; - } fprintf(stdout,"%s: ",(file == NULL)?"stdin":file); csc = X509_STORE_CTX_new(); @@ -288,7 +265,6 @@ end: else ERR_print_errors(bio_err); if (x != NULL) X509_free(x); - if (in != NULL) BIO_free(in); return(ret); } |