10Sstevel@tonic-gate /* apps/verify.c */
20Sstevel@tonic-gate /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
30Sstevel@tonic-gate * All rights reserved.
40Sstevel@tonic-gate *
50Sstevel@tonic-gate * This package is an SSL implementation written
60Sstevel@tonic-gate * by Eric Young (eay@cryptsoft.com).
70Sstevel@tonic-gate * The implementation was written so as to conform with Netscapes SSL.
80Sstevel@tonic-gate *
90Sstevel@tonic-gate * This library is free for commercial and non-commercial use as long as
100Sstevel@tonic-gate * the following conditions are aheared to. The following conditions
110Sstevel@tonic-gate * apply to all code found in this distribution, be it the RC4, RSA,
120Sstevel@tonic-gate * lhash, DES, etc., code; not just the SSL code. The SSL documentation
130Sstevel@tonic-gate * included with this distribution is covered by the same copyright terms
140Sstevel@tonic-gate * except that the holder is Tim Hudson (tjh@cryptsoft.com).
150Sstevel@tonic-gate *
160Sstevel@tonic-gate * Copyright remains Eric Young's, and as such any Copyright notices in
170Sstevel@tonic-gate * the code are not to be removed.
180Sstevel@tonic-gate * If this package is used in a product, Eric Young should be given attribution
190Sstevel@tonic-gate * as the author of the parts of the library used.
200Sstevel@tonic-gate * This can be in the form of a textual message at program startup or
210Sstevel@tonic-gate * in documentation (online or textual) provided with the package.
220Sstevel@tonic-gate *
230Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without
240Sstevel@tonic-gate * modification, are permitted provided that the following conditions
250Sstevel@tonic-gate * are met:
260Sstevel@tonic-gate * 1. Redistributions of source code must retain the copyright
270Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer.
280Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright
290Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in the
300Sstevel@tonic-gate * documentation and/or other materials provided with the distribution.
310Sstevel@tonic-gate * 3. All advertising materials mentioning features or use of this software
320Sstevel@tonic-gate * must display the following acknowledgement:
330Sstevel@tonic-gate * "This product includes cryptographic software written by
340Sstevel@tonic-gate * Eric Young (eay@cryptsoft.com)"
350Sstevel@tonic-gate * The word 'cryptographic' can be left out if the rouines from the library
360Sstevel@tonic-gate * being used are not cryptographic related :-).
370Sstevel@tonic-gate * 4. If you include any Windows specific code (or a derivative thereof) from
380Sstevel@tonic-gate * the apps directory (application code) you must include an acknowledgement:
390Sstevel@tonic-gate * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
400Sstevel@tonic-gate *
410Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
420Sstevel@tonic-gate * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
430Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
440Sstevel@tonic-gate * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
450Sstevel@tonic-gate * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
460Sstevel@tonic-gate * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
470Sstevel@tonic-gate * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
480Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
490Sstevel@tonic-gate * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
500Sstevel@tonic-gate * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
510Sstevel@tonic-gate * SUCH DAMAGE.
520Sstevel@tonic-gate *
530Sstevel@tonic-gate * The licence and distribution terms for any publically available version or
540Sstevel@tonic-gate * derivative of this code cannot be changed. i.e. this code cannot simply be
550Sstevel@tonic-gate * copied and put under another distribution licence
560Sstevel@tonic-gate * [including the GNU Public Licence.]
570Sstevel@tonic-gate */
580Sstevel@tonic-gate
590Sstevel@tonic-gate #include <stdio.h>
600Sstevel@tonic-gate #include <stdlib.h>
610Sstevel@tonic-gate #include <string.h>
620Sstevel@tonic-gate #include "apps.h"
630Sstevel@tonic-gate #include <openssl/bio.h>
640Sstevel@tonic-gate #include <openssl/err.h>
650Sstevel@tonic-gate #include <openssl/x509.h>
660Sstevel@tonic-gate #include <openssl/x509v3.h>
670Sstevel@tonic-gate #include <openssl/pem.h>
680Sstevel@tonic-gate
690Sstevel@tonic-gate #undef PROG
700Sstevel@tonic-gate #define PROG verify_main
710Sstevel@tonic-gate
720Sstevel@tonic-gate static int MS_CALLBACK cb(int ok, X509_STORE_CTX *ctx);
730Sstevel@tonic-gate static int check(X509_STORE *ctx, char *file, STACK_OF(X509) *uchain, STACK_OF(X509) *tchain, int purpose, ENGINE *e);
740Sstevel@tonic-gate static STACK_OF(X509) *load_untrusted(char *file);
750Sstevel@tonic-gate static int v_verbose=0, vflags = 0;
760Sstevel@tonic-gate
770Sstevel@tonic-gate int MAIN(int, char **);
780Sstevel@tonic-gate
MAIN(int argc,char ** argv)790Sstevel@tonic-gate int MAIN(int argc, char **argv)
800Sstevel@tonic-gate {
810Sstevel@tonic-gate ENGINE *e = NULL;
822139Sjp161948 int i,ret=1, badarg = 0;
830Sstevel@tonic-gate int purpose = -1;
840Sstevel@tonic-gate char *CApath=NULL,*CAfile=NULL;
850Sstevel@tonic-gate char *untfile = NULL, *trustfile = NULL;
860Sstevel@tonic-gate STACK_OF(X509) *untrusted = NULL, *trusted = NULL;
870Sstevel@tonic-gate X509_STORE *cert_ctx=NULL;
880Sstevel@tonic-gate X509_LOOKUP *lookup=NULL;
892139Sjp161948 X509_VERIFY_PARAM *vpm = NULL;
900Sstevel@tonic-gate #ifndef OPENSSL_NO_ENGINE
910Sstevel@tonic-gate char *engine=NULL;
920Sstevel@tonic-gate #endif
930Sstevel@tonic-gate
940Sstevel@tonic-gate cert_ctx=X509_STORE_new();
950Sstevel@tonic-gate if (cert_ctx == NULL) goto end;
960Sstevel@tonic-gate X509_STORE_set_verify_cb_func(cert_ctx,cb);
970Sstevel@tonic-gate
980Sstevel@tonic-gate ERR_load_crypto_strings();
990Sstevel@tonic-gate
1000Sstevel@tonic-gate apps_startup();
1010Sstevel@tonic-gate
1020Sstevel@tonic-gate if (bio_err == NULL)
1030Sstevel@tonic-gate if ((bio_err=BIO_new(BIO_s_file())) != NULL)
1040Sstevel@tonic-gate BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
1050Sstevel@tonic-gate
1060Sstevel@tonic-gate if (!load_config(bio_err, NULL))
1070Sstevel@tonic-gate goto end;
1080Sstevel@tonic-gate
1090Sstevel@tonic-gate argc--;
1100Sstevel@tonic-gate argv++;
1110Sstevel@tonic-gate for (;;)
1120Sstevel@tonic-gate {
1130Sstevel@tonic-gate if (argc >= 1)
1140Sstevel@tonic-gate {
1150Sstevel@tonic-gate if (strcmp(*argv,"-CApath") == 0)
1160Sstevel@tonic-gate {
1170Sstevel@tonic-gate if (argc-- < 1) goto end;
1180Sstevel@tonic-gate CApath= *(++argv);
1190Sstevel@tonic-gate }
1200Sstevel@tonic-gate else if (strcmp(*argv,"-CAfile") == 0)
1210Sstevel@tonic-gate {
1220Sstevel@tonic-gate if (argc-- < 1) goto end;
1230Sstevel@tonic-gate CAfile= *(++argv);
1240Sstevel@tonic-gate }
1252139Sjp161948 else if (args_verify(&argv, &argc, &badarg, bio_err,
1262139Sjp161948 &vpm))
1270Sstevel@tonic-gate {
1282139Sjp161948 if (badarg)
1290Sstevel@tonic-gate goto end;
1302139Sjp161948 continue;
1310Sstevel@tonic-gate }
1320Sstevel@tonic-gate else if (strcmp(*argv,"-untrusted") == 0)
1330Sstevel@tonic-gate {
1340Sstevel@tonic-gate if (argc-- < 1) goto end;
1350Sstevel@tonic-gate untfile= *(++argv);
1360Sstevel@tonic-gate }
1370Sstevel@tonic-gate else if (strcmp(*argv,"-trusted") == 0)
1380Sstevel@tonic-gate {
1390Sstevel@tonic-gate if (argc-- < 1) goto end;
1400Sstevel@tonic-gate trustfile= *(++argv);
1410Sstevel@tonic-gate }
1420Sstevel@tonic-gate #ifndef OPENSSL_NO_ENGINE
1430Sstevel@tonic-gate else if (strcmp(*argv,"-engine") == 0)
1440Sstevel@tonic-gate {
1450Sstevel@tonic-gate if (--argc < 1) goto end;
1460Sstevel@tonic-gate engine= *(++argv);
1470Sstevel@tonic-gate }
1480Sstevel@tonic-gate #endif
1490Sstevel@tonic-gate else if (strcmp(*argv,"-help") == 0)
1500Sstevel@tonic-gate goto end;
1510Sstevel@tonic-gate else if (strcmp(*argv,"-verbose") == 0)
1520Sstevel@tonic-gate v_verbose=1;
1530Sstevel@tonic-gate else if (argv[0][0] == '-')
1540Sstevel@tonic-gate goto end;
1550Sstevel@tonic-gate else
1560Sstevel@tonic-gate break;
1570Sstevel@tonic-gate argc--;
1580Sstevel@tonic-gate argv++;
1590Sstevel@tonic-gate }
1600Sstevel@tonic-gate else
1610Sstevel@tonic-gate break;
1620Sstevel@tonic-gate }
1630Sstevel@tonic-gate
1640Sstevel@tonic-gate #ifndef OPENSSL_NO_ENGINE
1650Sstevel@tonic-gate e = setup_engine(bio_err, engine, 0);
1660Sstevel@tonic-gate #endif
1670Sstevel@tonic-gate
1682139Sjp161948 if (vpm)
1692139Sjp161948 X509_STORE_set1_param(cert_ctx, vpm);
1702139Sjp161948
1710Sstevel@tonic-gate lookup=X509_STORE_add_lookup(cert_ctx,X509_LOOKUP_file());
1720Sstevel@tonic-gate if (lookup == NULL) abort();
1730Sstevel@tonic-gate if (CAfile) {
1740Sstevel@tonic-gate i=X509_LOOKUP_load_file(lookup,CAfile,X509_FILETYPE_PEM);
1750Sstevel@tonic-gate if(!i) {
1760Sstevel@tonic-gate BIO_printf(bio_err, "Error loading file %s\n", CAfile);
1770Sstevel@tonic-gate ERR_print_errors(bio_err);
1780Sstevel@tonic-gate goto end;
1790Sstevel@tonic-gate }
1800Sstevel@tonic-gate } else X509_LOOKUP_load_file(lookup,NULL,X509_FILETYPE_DEFAULT);
1810Sstevel@tonic-gate
1820Sstevel@tonic-gate lookup=X509_STORE_add_lookup(cert_ctx,X509_LOOKUP_hash_dir());
1830Sstevel@tonic-gate if (lookup == NULL) abort();
1840Sstevel@tonic-gate if (CApath) {
1850Sstevel@tonic-gate i=X509_LOOKUP_add_dir(lookup,CApath,X509_FILETYPE_PEM);
1860Sstevel@tonic-gate if(!i) {
1870Sstevel@tonic-gate BIO_printf(bio_err, "Error loading directory %s\n", CApath);
1880Sstevel@tonic-gate ERR_print_errors(bio_err);
1890Sstevel@tonic-gate goto end;
1900Sstevel@tonic-gate }
1910Sstevel@tonic-gate } else X509_LOOKUP_add_dir(lookup,NULL,X509_FILETYPE_DEFAULT);
1920Sstevel@tonic-gate
1930Sstevel@tonic-gate ERR_clear_error();
1940Sstevel@tonic-gate
1950Sstevel@tonic-gate if(untfile) {
1960Sstevel@tonic-gate if(!(untrusted = load_untrusted(untfile))) {
1970Sstevel@tonic-gate BIO_printf(bio_err, "Error loading untrusted file %s\n", untfile);
1980Sstevel@tonic-gate ERR_print_errors(bio_err);
1990Sstevel@tonic-gate goto end;
2000Sstevel@tonic-gate }
2010Sstevel@tonic-gate }
2020Sstevel@tonic-gate
2030Sstevel@tonic-gate if(trustfile) {
2040Sstevel@tonic-gate if(!(trusted = load_untrusted(trustfile))) {
2050Sstevel@tonic-gate BIO_printf(bio_err, "Error loading untrusted file %s\n", trustfile);
2060Sstevel@tonic-gate ERR_print_errors(bio_err);
2070Sstevel@tonic-gate goto end;
2080Sstevel@tonic-gate }
2090Sstevel@tonic-gate }
2100Sstevel@tonic-gate
2110Sstevel@tonic-gate if (argc < 1) check(cert_ctx, NULL, untrusted, trusted, purpose, e);
2120Sstevel@tonic-gate else
2130Sstevel@tonic-gate for (i=0; i<argc; i++)
2140Sstevel@tonic-gate check(cert_ctx,argv[i], untrusted, trusted, purpose, e);
2150Sstevel@tonic-gate ret=0;
2160Sstevel@tonic-gate end:
2170Sstevel@tonic-gate if (ret == 1) {
2180Sstevel@tonic-gate BIO_printf(bio_err,"usage: verify [-verbose] [-CApath path] [-CAfile file] [-purpose purpose] [-crl_check]");
2190Sstevel@tonic-gate #ifndef OPENSSL_NO_ENGINE
2200Sstevel@tonic-gate BIO_printf(bio_err," [-engine e]");
2210Sstevel@tonic-gate #endif
2220Sstevel@tonic-gate BIO_printf(bio_err," cert1 cert2 ...\n");
2230Sstevel@tonic-gate BIO_printf(bio_err,"recognized usages:\n");
2240Sstevel@tonic-gate for(i = 0; i < X509_PURPOSE_get_count(); i++) {
2250Sstevel@tonic-gate X509_PURPOSE *ptmp;
2260Sstevel@tonic-gate ptmp = X509_PURPOSE_get0(i);
2270Sstevel@tonic-gate BIO_printf(bio_err, "\t%-10s\t%s\n", X509_PURPOSE_get0_sname(ptmp),
2280Sstevel@tonic-gate X509_PURPOSE_get0_name(ptmp));
2290Sstevel@tonic-gate }
2300Sstevel@tonic-gate }
2312139Sjp161948 if (vpm) X509_VERIFY_PARAM_free(vpm);
2320Sstevel@tonic-gate if (cert_ctx != NULL) X509_STORE_free(cert_ctx);
2330Sstevel@tonic-gate sk_X509_pop_free(untrusted, X509_free);
2340Sstevel@tonic-gate sk_X509_pop_free(trusted, X509_free);
2350Sstevel@tonic-gate apps_shutdown();
2360Sstevel@tonic-gate OPENSSL_EXIT(ret);
2370Sstevel@tonic-gate }
2380Sstevel@tonic-gate
check(X509_STORE * ctx,char * file,STACK_OF (X509)* uchain,STACK_OF (X509)* tchain,int purpose,ENGINE * e)2390Sstevel@tonic-gate static int check(X509_STORE *ctx, char *file, STACK_OF(X509) *uchain, STACK_OF(X509) *tchain, int purpose, ENGINE *e)
2400Sstevel@tonic-gate {
2410Sstevel@tonic-gate X509 *x=NULL;
2420Sstevel@tonic-gate int i=0,ret=0;
2430Sstevel@tonic-gate X509_STORE_CTX *csc;
2440Sstevel@tonic-gate
2450Sstevel@tonic-gate x = load_cert(bio_err, file, FORMAT_PEM, NULL, e, "certificate file");
2460Sstevel@tonic-gate if (x == NULL)
2470Sstevel@tonic-gate goto end;
2480Sstevel@tonic-gate fprintf(stdout,"%s: ",(file == NULL)?"stdin":file);
2490Sstevel@tonic-gate
2500Sstevel@tonic-gate csc = X509_STORE_CTX_new();
2510Sstevel@tonic-gate if (csc == NULL)
2520Sstevel@tonic-gate {
2530Sstevel@tonic-gate ERR_print_errors(bio_err);
2540Sstevel@tonic-gate goto end;
2550Sstevel@tonic-gate }
2560Sstevel@tonic-gate X509_STORE_set_flags(ctx, vflags);
2570Sstevel@tonic-gate if(!X509_STORE_CTX_init(csc,ctx,x,uchain))
2580Sstevel@tonic-gate {
2590Sstevel@tonic-gate ERR_print_errors(bio_err);
2600Sstevel@tonic-gate goto end;
2610Sstevel@tonic-gate }
2620Sstevel@tonic-gate if(tchain) X509_STORE_CTX_trusted_stack(csc, tchain);
2630Sstevel@tonic-gate if(purpose >= 0) X509_STORE_CTX_set_purpose(csc, purpose);
2640Sstevel@tonic-gate i=X509_verify_cert(csc);
2650Sstevel@tonic-gate X509_STORE_CTX_free(csc);
2660Sstevel@tonic-gate
2670Sstevel@tonic-gate ret=0;
2680Sstevel@tonic-gate end:
269*8545SJan.Pechanec@Sun.COM if (i > 0)
2700Sstevel@tonic-gate {
2710Sstevel@tonic-gate fprintf(stdout,"OK\n");
2720Sstevel@tonic-gate ret=1;
2730Sstevel@tonic-gate }
2740Sstevel@tonic-gate else
2750Sstevel@tonic-gate ERR_print_errors(bio_err);
2760Sstevel@tonic-gate if (x != NULL) X509_free(x);
2770Sstevel@tonic-gate
2780Sstevel@tonic-gate return(ret);
2790Sstevel@tonic-gate }
2800Sstevel@tonic-gate
STACK_OF(X509)2810Sstevel@tonic-gate static STACK_OF(X509) *load_untrusted(char *certfile)
2820Sstevel@tonic-gate {
2830Sstevel@tonic-gate STACK_OF(X509_INFO) *sk=NULL;
2840Sstevel@tonic-gate STACK_OF(X509) *stack=NULL, *ret=NULL;
2850Sstevel@tonic-gate BIO *in=NULL;
2860Sstevel@tonic-gate X509_INFO *xi;
2870Sstevel@tonic-gate
2880Sstevel@tonic-gate if(!(stack = sk_X509_new_null())) {
2890Sstevel@tonic-gate BIO_printf(bio_err,"memory allocation failure\n");
2900Sstevel@tonic-gate goto end;
2910Sstevel@tonic-gate }
2920Sstevel@tonic-gate
2930Sstevel@tonic-gate if(!(in=BIO_new_file(certfile, "r"))) {
2940Sstevel@tonic-gate BIO_printf(bio_err,"error opening the file, %s\n",certfile);
2950Sstevel@tonic-gate goto end;
2960Sstevel@tonic-gate }
2970Sstevel@tonic-gate
2980Sstevel@tonic-gate /* This loads from a file, a stack of x509/crl/pkey sets */
2990Sstevel@tonic-gate if(!(sk=PEM_X509_INFO_read_bio(in,NULL,NULL,NULL))) {
3000Sstevel@tonic-gate BIO_printf(bio_err,"error reading the file, %s\n",certfile);
3010Sstevel@tonic-gate goto end;
3020Sstevel@tonic-gate }
3030Sstevel@tonic-gate
3040Sstevel@tonic-gate /* scan over it and pull out the certs */
3050Sstevel@tonic-gate while (sk_X509_INFO_num(sk))
3060Sstevel@tonic-gate {
3070Sstevel@tonic-gate xi=sk_X509_INFO_shift(sk);
3080Sstevel@tonic-gate if (xi->x509 != NULL)
3090Sstevel@tonic-gate {
3100Sstevel@tonic-gate sk_X509_push(stack,xi->x509);
3110Sstevel@tonic-gate xi->x509=NULL;
3120Sstevel@tonic-gate }
3130Sstevel@tonic-gate X509_INFO_free(xi);
3140Sstevel@tonic-gate }
3150Sstevel@tonic-gate if(!sk_X509_num(stack)) {
3160Sstevel@tonic-gate BIO_printf(bio_err,"no certificates in file, %s\n",certfile);
3170Sstevel@tonic-gate sk_X509_free(stack);
3180Sstevel@tonic-gate goto end;
3190Sstevel@tonic-gate }
3200Sstevel@tonic-gate ret=stack;
3210Sstevel@tonic-gate end:
3220Sstevel@tonic-gate BIO_free(in);
3230Sstevel@tonic-gate sk_X509_INFO_free(sk);
3240Sstevel@tonic-gate return(ret);
3250Sstevel@tonic-gate }
3260Sstevel@tonic-gate
cb(int ok,X509_STORE_CTX * ctx)3270Sstevel@tonic-gate static int MS_CALLBACK cb(int ok, X509_STORE_CTX *ctx)
3280Sstevel@tonic-gate {
3290Sstevel@tonic-gate char buf[256];
3300Sstevel@tonic-gate
3310Sstevel@tonic-gate if (!ok)
3320Sstevel@tonic-gate {
3332139Sjp161948 if (ctx->current_cert)
3342139Sjp161948 {
3352139Sjp161948 X509_NAME_oneline(
3360Sstevel@tonic-gate X509_get_subject_name(ctx->current_cert),buf,
3370Sstevel@tonic-gate sizeof buf);
3382139Sjp161948 printf("%s\n",buf);
3392139Sjp161948 }
3400Sstevel@tonic-gate printf("error %d at %d depth lookup:%s\n",ctx->error,
3410Sstevel@tonic-gate ctx->error_depth,
3420Sstevel@tonic-gate X509_verify_cert_error_string(ctx->error));
3430Sstevel@tonic-gate if (ctx->error == X509_V_ERR_CERT_HAS_EXPIRED) ok=1;
3440Sstevel@tonic-gate /* since we are just checking the certificates, it is
3450Sstevel@tonic-gate * ok if they are self signed. But we should still warn
3460Sstevel@tonic-gate * the user.
3470Sstevel@tonic-gate */
3480Sstevel@tonic-gate if (ctx->error == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT) ok=1;
3490Sstevel@tonic-gate /* Continue after extension errors too */
3500Sstevel@tonic-gate if (ctx->error == X509_V_ERR_INVALID_CA) ok=1;
3512139Sjp161948 if (ctx->error == X509_V_ERR_INVALID_NON_CA) ok=1;
3520Sstevel@tonic-gate if (ctx->error == X509_V_ERR_PATH_LENGTH_EXCEEDED) ok=1;
3530Sstevel@tonic-gate if (ctx->error == X509_V_ERR_INVALID_PURPOSE) ok=1;
3540Sstevel@tonic-gate if (ctx->error == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT) ok=1;
3550Sstevel@tonic-gate if (ctx->error == X509_V_ERR_CRL_HAS_EXPIRED) ok=1;
3560Sstevel@tonic-gate if (ctx->error == X509_V_ERR_CRL_NOT_YET_VALID) ok=1;
3570Sstevel@tonic-gate if (ctx->error == X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION) ok=1;
3582139Sjp161948
3592139Sjp161948 if (ctx->error == X509_V_ERR_NO_EXPLICIT_POLICY)
3602139Sjp161948 policies_print(NULL, ctx);
3612139Sjp161948 return ok;
3622139Sjp161948
3630Sstevel@tonic-gate }
3642139Sjp161948 if ((ctx->error == X509_V_OK) && (ok == 2))
3652139Sjp161948 policies_print(NULL, ctx);
3660Sstevel@tonic-gate if (!v_verbose)
3670Sstevel@tonic-gate ERR_clear_error();
3680Sstevel@tonic-gate return(ok);
3690Sstevel@tonic-gate }
3700Sstevel@tonic-gate
371