aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>1999-02-19 01:29:29 +0000
committerDr. Stephen Henson <steve@openssl.org>1999-02-19 01:29:29 +0000
commit0ca5f8b15c927d56004d3b53744ab68e6ec1b79b (patch)
treea04d70b9b38d66f1b52aa45ccddc39051da5ce14 /apps
parent6b056c414d1a80055405976ddf09d4dfee85ecf8 (diff)
downloadopenssl-0ca5f8b15c927d56004d3b53744ab68e6ec1b79b.tar.gz
Overhaul 'crl' application, add a proper X509_CRL_print function and start
to support CRL extensions.
Diffstat (limited to 'apps')
-rw-r--r--apps/crl.c59
1 files changed, 18 insertions, 41 deletions
diff --git a/apps/crl.c b/apps/crl.c
index a0098e9efd..a35e85733b 100644
--- a/apps/crl.c
+++ b/apps/crl.c
@@ -63,6 +63,7 @@
#include "bio.h"
#include "err.h"
#include "x509.h"
+#include "x509v3.h"
#include "pem.h"
#undef PROG
@@ -104,7 +105,7 @@ char **argv;
BIO *out=NULL;
int informat,outformat;
char *infile=NULL,*outfile=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();
@@ -142,10 +143,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;
@@ -156,6 +153,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)
@@ -176,14 +175,6 @@ char **argv;
argv++;
}
- if (outformat == FORMAT_TEXT)
- {
- num=0;
- issuer= ++num;
- lastupdate= ++num;
- nextupdate= ++num;
- }
-
if (badops)
{
bad:
@@ -193,6 +184,7 @@ bad:
}
ERR_load_crypto_strings();
+ X509V3_add_standard_extensions();
x=load_crl(infile,informat);
if (x == NULL) { goto end; }
@@ -203,28 +195,28 @@ bad:
if (issuer == i)
{
X509_NAME_oneline(x->crl->issuer,buf,256);
- fprintf(stdout,"issuer= %s\n",buf);
+ 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=");
+ BIO_printf(bio_out,"lastUpdate=");
ASN1_TIME_print(bio_out,x->crl->lastUpdate);
- fprintf(stdout,"\n");
+ BIO_printf(bio_out,"\n");
}
if (nextupdate == i)
{
- fprintf(stdout,"nextUpdate=");
+ BIO_printf(bio_out,"nextUpdate=");
if (x->crl->nextUpdate != NULL)
ASN1_TIME_print(bio_out,x->crl->nextUpdate);
else
- fprintf(stdout,"NONE");
- fprintf(stdout,"\n");
+ BIO_printf(bio_out,"NONE");
+ BIO_printf(bio_out,"\n");
}
}
}
@@ -249,27 +241,11 @@ bad:
}
}
+ if (text) X509_CRL_print(out, x);
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;
- STACK *sk;
-
- sk=sk_dup(x->crl->revoked);
- while ((r=(X509_REVOKED *)sk_pop(sk)) != NULL)
- {
- fprintf(stdout,"revoked: serialNumber=");
- i2a_ASN1_INTEGER(out,r->serialNumber);
- fprintf(stdout," revocationDate=");
- ASN1_TIME_print(bio_out,r->revocationDate);
- fprintf(stdout,"\n");
- }
- sk_free(sk);
- i=1;
- }
else
{
BIO_printf(bio_err,"bad output format specified for outfile\n");
@@ -278,9 +254,10 @@ 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);
}
@@ -324,7 +301,7 @@ int format;
}
end:
- if (in != NULL) BIO_free(in);
+ BIO_free(in);
return(x);
}