Hi, this patch allows for public key structure retrivial when using the 'req' command. Following are the details:
Added Switch:
o -pubkey output public key
Fixes:
o printing of "using config file... " only if -verbose is used
Comments:
The patch is indeed very simple and adds just the possiblity to
have the public key printed out.
Let me know about the status of this patch, thanks.
--
C'you,
Massimiliano Pala
--o-------------------------------------------------------------------------
Massimiliano Pala [OpenCA Project Manager] [EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
http://www.openca.org Tel.: +39 (0)59 270 094
http://openca.sourceforge.net Mobile: +39 (0)347 7222 365
--- req.c Fri Nov 2 15:00:10 2001
+++ req.c.mod Thu Nov 22 18:43:05 2001
@@ -106,6 +106,7 @@
* -rand file(s) - load the file(s) into the PRNG.
* -newkey - make a key and a request.
* -modulus - print RSA modulus.
+ * -pubkey - print Public Key.
* -x509 - output a self signed X509 structure instead.
* -asn1-kludge - output new certificate request in a format that some CA's
* require. This format is wrong
@@ -159,7 +160,7 @@
long newkey = -1;
BIO *in=NULL,*out=NULL;
int informat,outformat,verify=0,noout=0,text=0,keyform=FORMAT_PEM;
- int nodes=0,kludge=0,newhdr=0,subject=0;
+ int nodes=0,kludge=0,newhdr=0,subject=0,pubkey=0;
char *infile,*outfile,*prog,*keyfile=NULL,*template=NULL,*keyout=NULL;
char *engine=NULL;
char *extensions = NULL;
@@ -218,6 +219,10 @@
if (--argc < 1) goto bad;
keyfile= *(++argv);
}
+ else if (strcmp(*argv,"-pubkey") == 0)
+ {
+ pubkey=1;
+ }
else if (strcmp(*argv,"-new") == 0)
{
newreq=1;
@@ -412,6 +417,7 @@
BIO_printf(bio_err," -in arg input file\n");
BIO_printf(bio_err," -out arg output file\n");
BIO_printf(bio_err," -text text form of request\n");
+ BIO_printf(bio_err," -pubkey output public key\n");
BIO_printf(bio_err," -noout do not output REQ\n");
BIO_printf(bio_err," -verify verify signature on REQ\n");
BIO_printf(bio_err," -modulus RSA modulus\n");
@@ -473,7 +479,8 @@
{
long errline;
- BIO_printf(bio_err,"Using configuration from %s\n",template);
+ if( verbose )
+ BIO_printf(bio_err,"Using configuration from %s\n",template);
req_conf=NCONF_new(NULL);
i=NCONF_load(req_conf,template,&errline);
if (i == 0)
@@ -485,7 +492,8 @@
else
{
req_conf=config;
- BIO_printf(bio_err,"Using configuration from %s\n",
+ if( verbose )
+ BIO_printf(bio_err,"Using configuration from %s\n",
default_config_file);
if (req_conf == NULL)
{
@@ -922,7 +930,7 @@
BIO_printf(bio_err,"verify OK\n");
}
- if (noout && !text && !modulus && !subject)
+ if (noout && !text && !modulus && !subject && !pubkey)
{
ex=0;
goto end;
@@ -949,6 +957,20 @@
perror(outfile);
goto end;
}
+ }
+
+ if (pubkey)
+ {
+ EVP_PKEY *pkey;
+ pkey=pkey=X509_REQ_get_pubkey(req);
+ if (pkey == NULL)
+ {
+ BIO_printf(bio_err,"Error getting public key\n");
+ ERR_print_errors(bio_err);
+ goto end;
+ }
+ PEM_write_bio_PUBKEY( out, pkey);
+ EVP_PKEY_free(pkey);
}
if (text)
--- req.pod Thu Nov 22 18:38:33 2001 +++ req.pod.mod Thu Nov 22 18:38:14 2001 @@ -15,6 +15,7 @@ [B<-out filename>] [B<-passout arg>] [B<-text>] +[B<-pubkey>] [B<-noout>] [B<-verify>] [B<-modulus>] @@ -86,6 +87,10 @@ =item B<-text> prints out the certificate request in text form. + +=item B<-pubkey> + +prints out the public key structure. =item B<-noout>
smime.p7s
Description: S/MIME Cryptographic Signature
