I need to extract some info from a certificate
and put them in a text file, in order to "import" them in a DB (mysql,
Access,...)
I need this info :
serial number, subject, dates, purpose, pubkey, but
STRUCTURED, that is, for example :
3GF6000D9/ US/ MY OFFICE / SECTION/ SMITH /
PAUL / [EMAIL PROTECTED] / 0 / 0 / 0 / 0 / 0 /
...1/ ..../ 1 / 1 / May 7 14:27:37 2000 / May 7 14:27:37
2005 / MIGgMA0GCSqGSIb3DQEBA.../
that correspond to :
serial / C/ O /OU / CN / EMAIL /
SSL client / SSL client CA / ...../ Any
Purpose / Any Purpose CA / notBefore / notAfte / PUBLIC
KEY
I've used the following command :
openssl x509 -inform DER -in %1 -serial -subject
-dates -purpose -pubkey -noout>%1.txt
but I do not obtain what I need, because the result
is :
serial=3999;
subject= /C=US/O=.../..
Certificate purposes: SSL client : No SL client CA
: No SL server : No SL server CA : No ....
notBefore=May...
notAfter=May ...
-----BEGIN PUBLIC KEY----- ...
.....
So I tried to modify x509.c as above (using
"-issuer" flag) :
......
if (num)
{ for (i=1; i<=num; i++) { if (issuer == i) { /* * "serial=" */ i2a_ASN1_INTEGER(STDout,x->cert_info->serialNumber); BIO_printf(STDout,"\n"); /* * "notAfter=" */ print_name(STDout, X509_get_subject_name(x), nmflag); /* * "notBefore=" */ BIO_printf(STDout,"/"); ASN1_TIME_print(STDout,X509_get_notBefore(x)); BIO_puts(STDout,"\n"); /* * "notAfter=" */ BIO_printf(STDout,"/"); ASN1_TIME_print(STDout,X509_get_notAfter(x)); BIO_puts(STDout,"\n"); BIO_printf(STDout,"/"); /* * "purpose=" */ X509_PURPOSE *ptmp; int j; BIO_printf(STDout, "Certificate purposes:\n"); for (j = 0; j < X509_PURPOSE_get_count(); j++) { ptmp = X509_PURPOSE_get0(j); purpose_print(STDout, x, ptmp) } /* * "publickey=" */ EVP_PKEY *pkey; pkey=X509_get_pubkey(x); PEM_write_bio_PUBKEY(STDout, pkey); EVP_PKEY_free(pkey); } , but I'm a VisualBasic programmer so I 've got no
result.
There could be a second manner in which I can do
the following command :
openssl x509 -inform DER
-in %1 -text -noout>%1.txt
and the "parse" the. txt file obtained, with
visualbasic commands
So the questions :
1) is it possible for anyone ogf you to "correct"
the x509.c ?
2) do you know an easiest method (parser)
?
Please help me.
Regards
Paolo
|