From: Dr. Stephen Henson Date: Fri, 18 Feb 2000 00:54:21 +0000 (+0000) Subject: New functions and option to use NEW in certificate requests. X-Git-Tag: OpenSSL_0_9_5beta1~51 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8a208cba97b0d08cfc6f07bb2f0e0d1f305a0b13;p=oweals%2Fopenssl.git New functions and option to use NEW in certificate requests. --- diff --git a/CHANGES b/CHANGES index 9f26576094..74253ca4e3 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,12 @@ Changes between 0.9.4 and 0.9.5 [xx XXX 2000] + *) Add some PEM_write_X509_REQ_NEW() functions and a command line + argument to 'req'. This is not because the function is newer or + better than others it just uses the work 'NEW' in the certificate + request header lines. Some software needs this. + [Steve Henson] + *) Reorganise password command line arguments: now passwords can be obtained from various sources. Delete the PEM_cb function and make it the default behaviour: i.e. if the callback is NULL and the diff --git a/apps/req.c b/apps/req.c index 07a47c607f..79a7394088 100644 --- a/apps/req.c +++ b/apps/req.c @@ -150,7 +150,7 @@ int MAIN(int argc, char **argv) int i,badops=0,newreq=0,newkey= -1,pkey_type=0; BIO *in=NULL,*out=NULL; int informat,outformat,verify=0,noout=0,text=0,keyform=FORMAT_PEM; - int nodes=0,kludge=0; + int nodes=0,kludge=0,newhdr=0; char *infile,*outfile,*prog,*keyfile=NULL,*template=NULL,*keyout=NULL; char *extensions = NULL; char *req_exts = NULL; @@ -306,6 +306,8 @@ int MAIN(int argc, char **argv) newreq=1; } + else if (strcmp(*argv,"-newhdr") == 0) + newhdr=1; else if (strcmp(*argv,"-modulus") == 0) modulus=1; else if (strcmp(*argv,"-verify") == 0) @@ -378,6 +380,7 @@ bad: BIO_printf(bio_err," -new new request.\n"); BIO_printf(bio_err," -x509 output a x509 structure instead of a cert. req.\n"); BIO_printf(bio_err," -days number of days a x509 generated by -x509 is valid for.\n"); + BIO_printf(bio_err," -newhdr output \"NEW\" in the header lines\n"); BIO_printf(bio_err," -asn1-kludge Output the 'request' in a format that is wrong but some CA's\n"); BIO_printf(bio_err," have been reported as requiring\n"); BIO_printf(bio_err," -extensions .. specify certificate extension section (override value in config file)\n"); @@ -834,9 +837,10 @@ loop: { if (outformat == FORMAT_ASN1) i=i2d_X509_REQ_bio(out,req); - else if (outformat == FORMAT_PEM) - i=PEM_write_bio_X509_REQ(out,req); - else { + else if (outformat == FORMAT_PEM) { + if(newhdr) i=PEM_write_bio_X509_REQ_NEW(out,req); + else i=PEM_write_bio_X509_REQ(out,req); + } else { BIO_printf(bio_err,"bad output format specified for outfile\n"); goto end; } diff --git a/crypto/pem/pem.h b/crypto/pem/pem.h index 26c313b2ef..e4bae0b4aa 100644 --- a/crypto/pem/pem.h +++ b/crypto/pem/pem.h @@ -534,6 +534,7 @@ DECLARE_PEM_rw(X509, X509) DECLARE_PEM_rw(X509_AUX, X509) DECLARE_PEM_rw(X509_REQ, X509_REQ) +DECLARE_PEM_write(X509_REQ_NEW, X509_REQ) DECLARE_PEM_rw(X509_CRL, X509_CRL) diff --git a/crypto/pem/pem_all.c b/crypto/pem/pem_all.c index a0b6032f75..f56788f6fd 100644 --- a/crypto/pem/pem_all.c +++ b/crypto/pem/pem_all.c @@ -78,6 +78,8 @@ IMPLEMENT_PEM_rw(X509_AUX, X509, PEM_STRING_X509_TRUSTED, X509_AUX) IMPLEMENT_PEM_rw(X509_REQ, X509_REQ, PEM_STRING_X509_REQ, X509_REQ) +IMPLEMENT_PEM_write(X509_REQ_NEW, X509_REQ, PEM_STRING_X509_REQ_OLD, X509_REQ) + IMPLEMENT_PEM_rw(X509_CRL, X509_CRL, PEM_STRING_X509_CRL, X509_CRL) IMPLEMENT_PEM_rw(PKCS7, PKCS7, PEM_STRING_PKCS7, PKCS7) diff --git a/doc/apps/req.pod b/doc/apps/req.pod index f5cb441b92..6500fee49b 100644 --- a/doc/apps/req.pod +++ b/doc/apps/req.pod @@ -29,7 +29,8 @@ B B [B<-config filename>] [B<-x509>] [B<-days n>] -[B<-noasn1-kludge>] +[B<-asn1-kludge>] +[B<-newhdr>] [B<-extensions section>] [B<-reqexts section>] @@ -180,6 +181,11 @@ B whereas the correct form does. It should be noted that very few CAs still require the use of this option. +=item B<-newhdr> + +Adds the word B to the PEM file header and footer lines on the outputed +request. Some software (Netscape certificate server) and some CAs need this. + =back =head1 CONFIGURATION FILE FORMAT @@ -302,9 +308,9 @@ just consist of field names and values: for example, This allows external programs (e.g. GUI based) to generate a template file with all the field names and values and just pass it to B. An example -of this kind of configuration files is contained in the B section. +of this kind of configuration file is contained in the B section. -Alternatively if the B option is absent or not set to B the the +Alternatively if the B option is absent or not set to B then the file contains field prompting information. It consists of lines of the form: fieldName="prompt" @@ -327,7 +333,7 @@ two characters long and must fit in a PrintableString). Some fields (such as organizationName) can be used more than once in a DN. This presents a problem because configuration files will not recognize the same name occurring twice. To avoid this problem -if the fieldName contains an some characters followed by a full stop +if the fieldName contains some characters followed by a full stop they will be ignored. So for example a second organizationName can be input by calling it "1.organizationName". @@ -335,8 +341,7 @@ The actual permitted field names are any object identifier short or long names. These are compiled into OpenSSL and include the usual values such as commonName, countryName, localityName, organizationName, organizationUnitName, stateOrPrivinceName. Additionally emailAddress -is include as well as name, surname, givenName initials and dnQualifier -are supported. +is include as well as name, surname, givenName initials and dnQualifier. Additional object identifiers can be defined with the B or B options in the configuration file. Any additional fields @@ -439,7 +444,7 @@ Sample configuration containing all field values: =head1 NOTES -The header and footer lines in the B format are respectively: +The header and footer lines in the B format are normally: -----BEGIN CERTIFICATE REQUEST---- -----END CERTIFICATE REQUEST---- @@ -449,7 +454,8 @@ some software (some versions of Netscape certificate server) instead needs: -----BEGIN NEW CERTIFICATE REQUEST---- -----END NEW CERTIFICATE REQUEST---- -but is otherwise compatible. Either form is accepted on input. +which is produced with the B<-newhdr> option but is otherwise compatible. +Either form is accepted transparently on input. The certificate requests generated by B with MSIE have extensions added. It includes the B extension which determines the type of diff --git a/util/libeay.num b/util/libeay.num index 90742171f3..e3a0f692c8 100755 --- a/util/libeay.num +++ b/util/libeay.num @@ -2222,3 +2222,5 @@ CRYPTO_dbg_get_options 2246 AUTHORITY_INFO_ACCESS_new 2247 CRYPTO_get_mem_debug_options 2248 des_crypt 2249 +PEM_write_bio_X509_REQ_NEW 2250 +PEM_write_X509_REQ_NEW 2251 diff --git a/util/mkdef.pl b/util/mkdef.pl index d288b5687f..476cb150ad 100755 --- a/util/mkdef.pl +++ b/util/mkdef.pl @@ -301,6 +301,18 @@ sub do_defs } $funcs{"PEM_read_bio_${1}"} = 1; $funcs{"PEM_write_bio_${1}"} = 1; + } elsif (/^DECLARE_PEM_write\s*\(\s*(\w*)\s*,/ || + /^DECLARE_PEM_write_cb\s*\(\s*(\w*)\s*,/ ) { + if($W32) { + $funcs{"PEM_write_${1}"} = 1; + } + $funcs{"PEM_write_bio_${1}"} = 1; + } elsif (/^DECLARE_PEM_read\s*\(\s*(\w*)\s*,/ || + /^DECLARE_PEM_read_cb\s*\(\s*(\w*)\s*,/ ) { + if($W32) { + $funcs{"PEM_read_${1}"} = 1; + } + $funcs{"PEM_read_bio_${1}"} = 1; } elsif ( ($tag{'TRUE'} != -1) && ($tag{'FreeBSD'} != 1) &&