Deleted Added
full compact
crl2p7.c (109999) crl2p7.c (238405)
1/* apps/crl2p7.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *

--- 49 unchanged lines hidden (view full) ---

58
59/* This was written by Gordon Chaffee <chaffee@plateau.cs.berkeley.edu>
60 * and donated 'to the cause' along with lots and lots of other fixes to
61 * the library. */
62
63#include <stdio.h>
64#include <string.h>
65#include <sys/types.h>
1/* apps/crl2p7.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *

--- 49 unchanged lines hidden (view full) ---

58
59/* This was written by Gordon Chaffee <chaffee@plateau.cs.berkeley.edu>
60 * and donated 'to the cause' along with lots and lots of other fixes to
61 * the library. */
62
63#include <stdio.h>
64#include <string.h>
65#include <sys/types.h>
66#include <sys/stat.h>
67#include "apps.h"
68#include <openssl/err.h>
69#include <openssl/evp.h>
70#include <openssl/x509.h>
71#include <openssl/pkcs7.h>
72#include <openssl/pem.h>
73#include <openssl/objects.h>
74

--- 13 unchanged lines hidden (view full) ---

88 {
89 int i,badops=0;
90 BIO *in=NULL,*out=NULL;
91 int informat,outformat;
92 char *infile,*outfile,*prog,*certfile;
93 PKCS7 *p7 = NULL;
94 PKCS7_SIGNED *p7s = NULL;
95 X509_CRL *crl=NULL;
66#include "apps.h"
67#include <openssl/err.h>
68#include <openssl/evp.h>
69#include <openssl/x509.h>
70#include <openssl/pkcs7.h>
71#include <openssl/pem.h>
72#include <openssl/objects.h>
73

--- 13 unchanged lines hidden (view full) ---

87 {
88 int i,badops=0;
89 BIO *in=NULL,*out=NULL;
90 int informat,outformat;
91 char *infile,*outfile,*prog,*certfile;
92 PKCS7 *p7 = NULL;
93 PKCS7_SIGNED *p7s = NULL;
94 X509_CRL *crl=NULL;
96 STACK *certflst=NULL;
95 STACK_OF(OPENSSL_STRING) *certflst=NULL;
97 STACK_OF(X509_CRL) *crl_stack=NULL;
98 STACK_OF(X509) *cert_stack=NULL;
99 int ret=1,nocrl=0;
100
101 apps_startup();
102
103 if (bio_err == NULL)
104 if ((bio_err=BIO_new(BIO_s_file())) != NULL)

--- 31 unchanged lines hidden (view full) ---

136 else if (strcmp(*argv,"-out") == 0)
137 {
138 if (--argc < 1) goto bad;
139 outfile= *(++argv);
140 }
141 else if (strcmp(*argv,"-certfile") == 0)
142 {
143 if (--argc < 1) goto bad;
96 STACK_OF(X509_CRL) *crl_stack=NULL;
97 STACK_OF(X509) *cert_stack=NULL;
98 int ret=1,nocrl=0;
99
100 apps_startup();
101
102 if (bio_err == NULL)
103 if ((bio_err=BIO_new(BIO_s_file())) != NULL)

--- 31 unchanged lines hidden (view full) ---

135 else if (strcmp(*argv,"-out") == 0)
136 {
137 if (--argc < 1) goto bad;
138 outfile= *(++argv);
139 }
140 else if (strcmp(*argv,"-certfile") == 0)
141 {
142 if (--argc < 1) goto bad;
144 if(!certflst) certflst = sk_new_null();
145 sk_push(certflst,*(++argv));
143 if(!certflst) certflst = sk_OPENSSL_STRING_new_null();
144 sk_OPENSSL_STRING_push(certflst,*(++argv));
146 }
147 else
148 {
149 BIO_printf(bio_err,"unknown option %s\n",*argv);
150 badops=1;
151 break;
152 }
153 argc--;

--- 68 unchanged lines hidden (view full) ---

222 {
223 sk_X509_CRL_push(crl_stack,crl);
224 crl=NULL; /* now part of p7 for OPENSSL_freeing */
225 }
226
227 if ((cert_stack=sk_X509_new_null()) == NULL) goto end;
228 p7s->cert=cert_stack;
229
145 }
146 else
147 {
148 BIO_printf(bio_err,"unknown option %s\n",*argv);
149 badops=1;
150 break;
151 }
152 argc--;

--- 68 unchanged lines hidden (view full) ---

221 {
222 sk_X509_CRL_push(crl_stack,crl);
223 crl=NULL; /* now part of p7 for OPENSSL_freeing */
224 }
225
226 if ((cert_stack=sk_X509_new_null()) == NULL) goto end;
227 p7s->cert=cert_stack;
228
230 if(certflst) for(i = 0; i < sk_num(certflst); i++) {
231 certfile = sk_value(certflst, i);
229 if(certflst) for(i = 0; i < sk_OPENSSL_STRING_num(certflst); i++) {
230 certfile = sk_OPENSSL_STRING_value(certflst, i);
232 if (add_certs_from_file(cert_stack,certfile) < 0)
233 {
234 BIO_printf(bio_err, "error loading certificates\n");
235 ERR_print_errors(bio_err);
236 goto end;
237 }
238 }
239
231 if (add_certs_from_file(cert_stack,certfile) < 0)
232 {
233 BIO_printf(bio_err, "error loading certificates\n");
234 ERR_print_errors(bio_err);
235 goto end;
236 }
237 }
238
240 sk_free(certflst);
239 sk_OPENSSL_STRING_free(certflst);
241
242 if (outfile == NULL)
243 {
244 BIO_set_fp(out,stdout,BIO_NOCLOSE);
245#ifdef OPENSSL_SYS_VMS
246 {
247 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
248 out = BIO_push(tmpbio, out);

--- 41 unchanged lines hidden (view full) ---

290 * Read a list of certificates to be checked from a file.
291 *
292 * Results:
293 * number of certs added if successful, -1 if not.
294 *----------------------------------------------------------------------
295 */
296static int add_certs_from_file(STACK_OF(X509) *stack, char *certfile)
297 {
240
241 if (outfile == NULL)
242 {
243 BIO_set_fp(out,stdout,BIO_NOCLOSE);
244#ifdef OPENSSL_SYS_VMS
245 {
246 BIO *tmpbio = BIO_new(BIO_f_linebuffer());
247 out = BIO_push(tmpbio, out);

--- 41 unchanged lines hidden (view full) ---

289 * Read a list of certificates to be checked from a file.
290 *
291 * Results:
292 * number of certs added if successful, -1 if not.
293 *----------------------------------------------------------------------
294 */
295static int add_certs_from_file(STACK_OF(X509) *stack, char *certfile)
296 {
298 struct stat st;
299 BIO *in=NULL;
300 int count=0;
301 int ret= -1;
302 STACK_OF(X509_INFO) *sk=NULL;
303 X509_INFO *xi;
304
297 BIO *in=NULL;
298 int count=0;
299 int ret= -1;
300 STACK_OF(X509_INFO) *sk=NULL;
301 X509_INFO *xi;
302
305 if ((stat(certfile,&st) != 0))
306 {
307 BIO_printf(bio_err,"unable to load the file, %s\n",certfile);
308 goto end;
309 }
310
311 in=BIO_new(BIO_s_file());
312 if ((in == NULL) || (BIO_read_filename(in,certfile) <= 0))
313 {
314 BIO_printf(bio_err,"error opening the file, %s\n",certfile);
315 goto end;
316 }
317
318 /* This loads from a file, a stack of x509/crl/pkey sets */

--- 27 unchanged lines hidden ---
303 in=BIO_new(BIO_s_file());
304 if ((in == NULL) || (BIO_read_filename(in,certfile) <= 0))
305 {
306 BIO_printf(bio_err,"error opening the file, %s\n",certfile);
307 goto end;
308 }
309
310 /* This loads from a file, a stack of x509/crl/pkey sets */

--- 27 unchanged lines hidden ---