X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=apps%2Fcrl.c;h=1b04f68ecfdb3d4315ecc760822d43a04bf9a639;hb=ddeee82c6333f27cb85940b271c3cc4d2e940717;hp=9642ee52684b9eb4eef0dfd11bc9607f5551ce60;hpb=d02b48c63a58ea4367a0e905979f140b7d090f86;p=oweals%2Fopenssl.git diff --git a/apps/crl.c b/apps/crl.c index 9642ee5268..1b04f68ecf 100644 --- a/apps/crl.c +++ b/apps/crl.c @@ -1,5 +1,5 @@ /* apps/crl.c */ -/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written @@ -60,10 +60,11 @@ #include #include #include "apps.h" -#include "bio.h" -#include "err.h" -#include "x509.h" -#include "pem.h" +#include +#include +#include +#include +#include #undef PROG #define PROG crl_main @@ -71,11 +72,6 @@ #undef POSTFIX #define POSTFIX ".rvk" -#define FORMAT_UNDEF 0 -#define FORMAT_ASN1 1 -#define FORMAT_TEXT 2 -#define FORMAT_PEM 3 - static char *crl_usage[]={ "usage: crl args\n", "\n", @@ -92,32 +88,24 @@ static char *crl_usage[]={ NULL }; -#ifndef NOPROTO static X509_CRL *load_crl(char *file, int format); -#else -static X509_CRL *load_crl(); -#endif - static BIO *bio_out=NULL; -int MAIN(argc, argv) -int argc; -char **argv; +int MAIN(int argc, char **argv) { X509_CRL *x=NULL; int ret=1,i,num,badops=0; BIO *out=NULL; int informat,outformat; char *infile=NULL,*outfile=NULL; - char *str=NULL; - int hash=0,issuer=0,lastupdate=0,nextupdate=0,noout=0; + int hash=0,issuer=0,lastupdate=0,nextupdate=0,noout=0,text=0; char **pp,buf[256]; apps_startup(); if (bio_err == NULL) if ((bio_err=BIO_new(BIO_s_file())) != NULL) - BIO_set_fp(bio_err,stderr,BIO_NOCLOSE); + BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); if (bio_out == NULL) if ((bio_out=BIO_new(BIO_s_file())) != NULL) @@ -148,10 +136,6 @@ char **argv; if (--argc < 1) goto bad; outformat=str2fmt(*(++argv)); } - else if (strcmp(*argv,"-text") == 0) - { - outformat=FORMAT_TEXT; - } else if (strcmp(*argv,"-in") == 0) { if (--argc < 1) goto bad; @@ -162,6 +146,8 @@ char **argv; if (--argc < 1) goto bad; outfile= *(++argv); } + else if (strcmp(*argv,"-text") == 0) + text = 1; else if (strcmp(*argv,"-hash") == 0) hash= ++num; else if (strcmp(*argv,"-issuer") == 0) @@ -182,14 +168,6 @@ char **argv; argv++; } - if (outformat == FORMAT_TEXT) - { - num=0; - issuer= ++num; - lastupdate= ++num; - nextupdate= ++num; - } - if (badops) { bad: @@ -199,6 +177,7 @@ bad: } ERR_load_crypto_strings(); + X509V3_add_standard_extensions(); x=load_crl(infile,informat); if (x == NULL) { goto end; } @@ -209,31 +188,32 @@ bad: if (issuer == i) { X509_NAME_oneline(x->crl->issuer,buf,256); - fprintf(stdout,"issuer= %s\n",str); + BIO_printf(bio_out,"issuer= %s\n",buf); } if (hash == i) { - fprintf(stdout,"%08lx\n", + BIO_printf(bio_out,"%08lx\n", X509_NAME_hash(x->crl->issuer)); } if (lastupdate == i) { - fprintf(stdout,"lastUpdate="); - ASN1_UTCTIME_print(bio_out,x->crl->lastUpdate); - fprintf(stdout,"\n"); + BIO_printf(bio_out,"lastUpdate="); + ASN1_TIME_print(bio_out,x->crl->lastUpdate); + BIO_printf(bio_out,"\n"); } if (nextupdate == i) { - fprintf(stdout,"nextUpdate="); - ASN1_UTCTIME_print(bio_out,x->crl->nextUpdate); - fprintf(stdout,"\n"); + BIO_printf(bio_out,"nextUpdate="); + if (x->crl->nextUpdate != NULL) + ASN1_TIME_print(bio_out,x->crl->nextUpdate); + else + BIO_printf(bio_out,"NONE"); + BIO_printf(bio_out,"\n"); } } } - if (noout) goto end; - out=BIO_new(BIO_s_file()); if (out == NULL) { @@ -252,24 +232,14 @@ bad: } } + if (text) X509_CRL_print(out, x); + + if (noout) goto end; + if (outformat == FORMAT_ASN1) i=(int)i2d_X509_CRL_bio(out,x); else if (outformat == FORMAT_PEM) i=PEM_write_bio_X509_CRL(out,x); - else if (outformat == FORMAT_TEXT) - { - X509_REVOKED *r; - - while ((r=(X509_REVOKED *)sk_pop(x->crl->revoked)) != NULL) - { - fprintf(stdout,"revoked: serialNumber="); - i2a_ASN1_INTEGER(out,r->serialNumber); - fprintf(stdout," revocationDate="); - ASN1_UTCTIME_print(bio_out,r->revocationDate); - fprintf(stdout,"\n"); - } - i=1; - } else { BIO_printf(bio_err,"bad output format specified for outfile\n"); @@ -278,15 +248,14 @@ bad: if (!i) { BIO_printf(bio_err,"unable to write CRL\n"); goto end; } ret=0; end: - if (out != NULL) BIO_free(out); - if (bio_out != NULL) BIO_free(bio_out); - if (x != NULL) X509_CRL_free(x); + BIO_free(out); + BIO_free(bio_out); + X509_CRL_free(x); + X509V3_EXT_cleanup(); EXIT(ret); } -static X509_CRL *load_crl(infile, format) -char *infile; -int format; +static X509_CRL *load_crl(char *infile, int format) { X509_CRL *x=NULL; BIO *in=NULL; @@ -324,7 +293,7 @@ int format; } end: - if (in != NULL) BIO_free(in); + BIO_free(in); return(x); }