Fix BN_[pseudo_]rand: 'mask' must be used even if top=-1.
[openssl.git] / apps / apps.c
index ca3f557ca2efd3b877eb7f5a96383988034d9749..a1397a36d8f60c2bd97ca04c5a20aa9832b03541 100644 (file)
@@ -476,7 +476,10 @@ X509 *load_cert(BIO *err, char *file, int format)
                }
 
        if (file == NULL)
+               {
+               setvbuf(stdin, NULL, _IONBF, 0);
                BIO_set_fp(cert,stdin,BIO_NOCLOSE);
+               }
        else
                {
                if (BIO_read_filename(cert,file) <= 0)
@@ -806,7 +809,7 @@ static int set_table_opts(unsigned long *flags, const char *arg, const NAME_EX_T
        } else c = 1;
 
        for(ptbl = in_tbl; ptbl->name; ptbl++) {
-               if(!strcmp(arg, ptbl->name)) {
+               if(!strcasecmp(arg, ptbl->name)) {
                        *flags &= ~ptbl->mask;
                        if(c) *flags |= ptbl->flag;
                        else *flags &= ~ptbl->flag;
@@ -837,3 +840,32 @@ void print_name(BIO *out, char *title, X509_NAME *nm, unsigned long lflags)
        }
 }
 
+X509_STORE *setup_verify(BIO *bp, char *CAfile, char *CApath)
+{
+       X509_STORE *store;
+       X509_LOOKUP *lookup;
+       if(!(store = X509_STORE_new())) goto end;
+       lookup=X509_STORE_add_lookup(store,X509_LOOKUP_file());
+       if (lookup == NULL) goto end;
+       if (CAfile) {
+               if(!X509_LOOKUP_load_file(lookup,CAfile,X509_FILETYPE_PEM)) {
+                       BIO_printf(bp, "Error loading file %s\n", CAfile);
+                       goto end;
+               }
+       } else X509_LOOKUP_load_file(lookup,NULL,X509_FILETYPE_DEFAULT);
+               
+       lookup=X509_STORE_add_lookup(store,X509_LOOKUP_hash_dir());
+       if (lookup == NULL) goto end;
+       if (CApath) {
+               if(!X509_LOOKUP_add_dir(lookup,CApath,X509_FILETYPE_PEM)) {
+                       BIO_printf(bp, "Error loading directory %s\n", CApath);
+                       goto end;
+               }
+       } else X509_LOOKUP_add_dir(lookup,NULL,X509_FILETYPE_DEFAULT);
+
+       ERR_clear_error();
+       return store;
+       end:
+       X509_STORE_free(store);
+       return NULL;
+}