diff options
author | beck <> | 2002-05-15 02:29:21 +0000 |
---|---|---|
committer | beck <> | 2002-05-15 02:29:21 +0000 |
commit | b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9 (patch) | |
tree | fa27cf82a1250b64ed3bf5f4a18c7354d470bbcc /src/lib/libssl/src/apps/crl.c | |
parent | e471e1ea98d673597b182ea85f29e30c97cd08b5 (diff) | |
download | openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.gz openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.tar.bz2 openbsd-b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9.zip |
OpenSSL 0.9.7 stable 2002 05 08 merge
Diffstat (limited to 'src/lib/libssl/src/apps/crl.c')
-rw-r--r-- | src/lib/libssl/src/apps/crl.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/lib/libssl/src/apps/crl.c b/src/lib/libssl/src/apps/crl.c index 3b5725f23f..00946b4d20 100644 --- a/src/lib/libssl/src/apps/crl.c +++ b/src/lib/libssl/src/apps/crl.c | |||
@@ -87,6 +87,7 @@ static char *crl_usage[]={ | |||
87 | " -noout - no CRL output\n", | 87 | " -noout - no CRL output\n", |
88 | " -CAfile name - verify CRL using certificates in file \"name\"\n", | 88 | " -CAfile name - verify CRL using certificates in file \"name\"\n", |
89 | " -CApath dir - verify CRL using certificates in \"dir\"\n", | 89 | " -CApath dir - verify CRL using certificates in \"dir\"\n", |
90 | " -nameopt arg - various certificate name options\n", | ||
90 | NULL | 91 | NULL |
91 | }; | 92 | }; |
92 | 93 | ||
@@ -97,6 +98,7 @@ int MAIN(int, char **); | |||
97 | 98 | ||
98 | int MAIN(int argc, char **argv) | 99 | int MAIN(int argc, char **argv) |
99 | { | 100 | { |
101 | unsigned long nmflag = 0; | ||
100 | X509_CRL *x=NULL; | 102 | X509_CRL *x=NULL; |
101 | char *CAfile = NULL, *CApath = NULL; | 103 | char *CAfile = NULL, *CApath = NULL; |
102 | int ret=1,i,num,badops=0; | 104 | int ret=1,i,num,badops=0; |
@@ -105,7 +107,7 @@ int MAIN(int argc, char **argv) | |||
105 | char *infile=NULL,*outfile=NULL; | 107 | char *infile=NULL,*outfile=NULL; |
106 | int hash=0,issuer=0,lastupdate=0,nextupdate=0,noout=0,text=0; | 108 | int hash=0,issuer=0,lastupdate=0,nextupdate=0,noout=0,text=0; |
107 | int fingerprint = 0; | 109 | int fingerprint = 0; |
108 | char **pp,buf[256]; | 110 | char **pp; |
109 | X509_STORE *store = NULL; | 111 | X509_STORE *store = NULL; |
110 | X509_STORE_CTX ctx; | 112 | X509_STORE_CTX ctx; |
111 | X509_LOOKUP *lookup = NULL; | 113 | X509_LOOKUP *lookup = NULL; |
@@ -120,11 +122,14 @@ int MAIN(int argc, char **argv) | |||
120 | if ((bio_err=BIO_new(BIO_s_file())) != NULL) | 122 | if ((bio_err=BIO_new(BIO_s_file())) != NULL) |
121 | BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); | 123 | BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); |
122 | 124 | ||
125 | if (!load_config(bio_err, NULL)) | ||
126 | goto end; | ||
127 | |||
123 | if (bio_out == NULL) | 128 | if (bio_out == NULL) |
124 | if ((bio_out=BIO_new(BIO_s_file())) != NULL) | 129 | if ((bio_out=BIO_new(BIO_s_file())) != NULL) |
125 | { | 130 | { |
126 | BIO_set_fp(bio_out,stdout,BIO_NOCLOSE); | 131 | BIO_set_fp(bio_out,stdout,BIO_NOCLOSE); |
127 | #ifdef VMS | 132 | #ifdef OPENSSL_SYS_VMS |
128 | { | 133 | { |
129 | BIO *tmpbio = BIO_new(BIO_f_linebuffer()); | 134 | BIO *tmpbio = BIO_new(BIO_f_linebuffer()); |
130 | bio_out = BIO_push(tmpbio, bio_out); | 135 | bio_out = BIO_push(tmpbio, bio_out); |
@@ -185,6 +190,11 @@ int MAIN(int argc, char **argv) | |||
185 | text = 1; | 190 | text = 1; |
186 | else if (strcmp(*argv,"-hash") == 0) | 191 | else if (strcmp(*argv,"-hash") == 0) |
187 | hash= ++num; | 192 | hash= ++num; |
193 | else if (strcmp(*argv,"-nameopt") == 0) | ||
194 | { | ||
195 | if (--argc < 1) goto bad; | ||
196 | if (!set_name_ex(&nmflag, *(++argv))) goto bad; | ||
197 | } | ||
188 | else if (strcmp(*argv,"-issuer") == 0) | 198 | else if (strcmp(*argv,"-issuer") == 0) |
189 | issuer= ++num; | 199 | issuer= ++num; |
190 | else if (strcmp(*argv,"-lastupdate") == 0) | 200 | else if (strcmp(*argv,"-lastupdate") == 0) |
@@ -214,7 +224,7 @@ int MAIN(int argc, char **argv) | |||
214 | { | 224 | { |
215 | bad: | 225 | bad: |
216 | for (pp=crl_usage; (*pp != NULL); pp++) | 226 | for (pp=crl_usage; (*pp != NULL); pp++) |
217 | BIO_printf(bio_err,*pp); | 227 | BIO_printf(bio_err,"%s",*pp); |
218 | goto end; | 228 | goto end; |
219 | } | 229 | } |
220 | 230 | ||
@@ -235,7 +245,11 @@ bad: | |||
235 | X509_LOOKUP_add_dir(lookup,NULL,X509_FILETYPE_DEFAULT); | 245 | X509_LOOKUP_add_dir(lookup,NULL,X509_FILETYPE_DEFAULT); |
236 | ERR_clear_error(); | 246 | ERR_clear_error(); |
237 | 247 | ||
238 | X509_STORE_CTX_init(&ctx, store, NULL, NULL); | 248 | if(!X509_STORE_CTX_init(&ctx, store, NULL, NULL)) { |
249 | BIO_printf(bio_err, | ||
250 | "Error initialising X509 store\n"); | ||
251 | goto end; | ||
252 | } | ||
239 | 253 | ||
240 | i = X509_STORE_get_by_subject(&ctx, X509_LU_X509, | 254 | i = X509_STORE_get_by_subject(&ctx, X509_LU_X509, |
241 | X509_CRL_get_issuer(x), &xobj); | 255 | X509_CRL_get_issuer(x), &xobj); |
@@ -264,9 +278,7 @@ bad: | |||
264 | { | 278 | { |
265 | if (issuer == i) | 279 | if (issuer == i) |
266 | { | 280 | { |
267 | X509_NAME_oneline(X509_CRL_get_issuer(x), | 281 | print_name(bio_out, "issuer=", X509_CRL_get_issuer(x), nmflag); |
268 | buf,256); | ||
269 | BIO_printf(bio_out,"issuer= %s\n",buf); | ||
270 | } | 282 | } |
271 | 283 | ||
272 | if (hash == i) | 284 | if (hash == i) |
@@ -324,7 +336,7 @@ bad: | |||
324 | if (outfile == NULL) | 336 | if (outfile == NULL) |
325 | { | 337 | { |
326 | BIO_set_fp(out,stdout,BIO_NOCLOSE); | 338 | BIO_set_fp(out,stdout,BIO_NOCLOSE); |
327 | #ifdef VMS | 339 | #ifdef OPENSSL_SYS_VMS |
328 | { | 340 | { |
329 | BIO *tmpbio = BIO_new(BIO_f_linebuffer()); | 341 | BIO *tmpbio = BIO_new(BIO_f_linebuffer()); |
330 | out = BIO_push(tmpbio, out); | 342 | out = BIO_push(tmpbio, out); |
@@ -364,6 +376,7 @@ end: | |||
364 | X509_STORE_CTX_cleanup(&ctx); | 376 | X509_STORE_CTX_cleanup(&ctx); |
365 | X509_STORE_free(store); | 377 | X509_STORE_free(store); |
366 | } | 378 | } |
379 | apps_shutdown(); | ||
367 | EXIT(ret); | 380 | EXIT(ret); |
368 | } | 381 | } |
369 | 382 | ||