#include <openssl/x509v3.h>
#include <openssl/objects.h>
#include <openssl/pem.h>
-#include <openssl/engine.h>
#undef PROG
#define PROG x509_main
" -fingerprint - print the certificate fingerprint\n",
" -alias - output certificate alias\n",
" -noout - no certificate output\n",
-" -ocspid - print OCSP hash values for the subject name and public key\n",
" -trustout - output a \"trusted\" certificate\n",
" -clrtrust - clear all trusted purposes\n",
" -clrreject - clear all rejected purposes\n",
" -extensions - section from config file with X509V3 extensions to add\n",
" -clrext - delete extensions before signing and input certificate\n",
" -nameopt arg - various certificate name options\n",
-" -engine e - use engine e, possibly a hardware device.\n",
-" -certopt arg - various certificate text options\n",
NULL
};
int MAIN(int argc, char **argv)
{
- ENGINE *e = NULL;
int ret=1;
X509_REQ *req=NULL;
X509 *x=NULL,*xca=NULL;
char *CAkeyfile=NULL,*CAserial=NULL;
char *alias=NULL;
int text=0,serial=0,hash=0,subject=0,issuer=0,startdate=0,enddate=0;
- int ocspid=0;
int noout=0,sign_flag=0,CA_flag=0,CA_createserial=0,email=0;
int trustout=0,clrtrust=0,clrreject=0,aliasout=0,clrext=0;
int C=0;
char *extsect = NULL, *extfile = NULL, *passin = NULL, *passargin = NULL;
int need_rand = 0;
int checkend=0,checkoffset=0;
- unsigned long nmflag = 0, certflag = 0;
- char *engine=NULL;
+ unsigned long nmflag = 0;
reqfile=0;
alias= *(++argv);
trustout = 1;
}
- else if (strcmp(*argv,"-certopt") == 0)
- {
- if (--argc < 1) goto bad;
- if (!set_cert_ex(&certflag, *(++argv))) goto bad;
- }
else if (strcmp(*argv,"-nameopt") == 0)
{
if (--argc < 1) goto bad;
alias= *(++argv);
trustout = 1;
}
- else if (strcmp(*argv,"-engine") == 0)
- {
- if (--argc < 1) goto bad;
- engine= *(++argv);
- }
else if (strcmp(*argv,"-C") == 0)
C= ++num;
else if (strcmp(*argv,"-email") == 0)
clrext = 1;
}
#endif
- else if (strcmp(*argv,"-ocspid") == 0)
- ocspid= ++num;
else if ((md_alg=EVP_get_digestbyname(*argv + 1)))
{
/* ok */
goto end;
}
- if (engine != NULL)
- {
- if((e = ENGINE_by_id(engine)) == NULL)
- {
- BIO_printf(bio_err,"invalid engine \"%s\"\n",
- engine);
- goto end;
- }
- if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
- {
- BIO_printf(bio_err,"can't use that engine\n");
- goto end;
- }
- BIO_printf(bio_err,"engine \"%s\" set.\n", engine);
- /* Free our "structural" reference. */
- ENGINE_free(e);
- }
-
if (need_rand)
app_RAND_load_file(NULL, bio_err, 0);
}
else if (text == i)
{
- X509_print_ex(out,x,nmflag, certflag);
+ X509_print(out,x);
}
else if (startdate == i)
{
BIO_printf(bio_err,"Generating certificate request\n");
+#ifndef NO_DSA
if (pk->type == EVP_PKEY_DSA)
digest=EVP_dss1();
+#endif
rq=X509_to_X509_REQ(x,pk,digest);
EVP_PKEY_free(pk);
}
noout=1;
}
- else if (ocspid == i)
- {
- X509_ocspid_print(out, x);
- }
}
}