[openssl.org #1109] Please urgently impelment "-utf8" parameter in "openssl ca" command

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[openssl.org #1109] Please urgently impelment "-utf8" parameter in "openssl ca" command

Rich Salz via RT

Finally a better way to fix it ;)

The fix adds a new command line switch to "openssl ca" function that
affects the way ?-subj? parameter is parsed. The new switch is named ?-
utf8? and makes possible to send the ?-subj? parameter as a string in
UTF8 format in order to generate RFC3280 subject that uses UTF8String
format.

Best regards
Stefan


Here is the diff file:
--- openssl-0.9.8-beta5\apps\ca.c.old 2005-04-15 21:29:33.000000000
+0300
+++ openssl-0.9.8-beta5\apps\ca.c 2005-06-14 13:10:22.908388000
+0300
@@ -174,6 +173,7 @@
 " -msie_hack      - msie modifications to handle all those universal
strings\n",
 " -revoke file    - Revoke a certificate (given in file)\n",
 " -subj arg       - Use arg instead of request's subject\n",
+" -utf8           - input characters are UTF8 (default ASCII)\n",
 " -multivalue-rdn - enable support for multivalued RDNs\n",
 " -extensions ..  - Extension section (override value in config file)
\n",
 " -extfile file   - Configuration file with X509v3 extentions to
add\n",
@@ -195,27 +195,27 @@
 static void lookup_fail(const char *name, const char *tag);
 static int certify(X509 **xret, char *infile,EVP_PKEY *pkey,X509
*x509,
    const EVP_MD *dgst,STACK_OF(CONF_VALUE)
*policy,CA_DB *db,
-   BIGNUM *serial, char *subj, int multirdn, int
email_dn, char *startdate,
+   BIGNUM *serial, char *subj,unsigned long chtype,
int multirdn, int email_dn, char *startdate,
    char *enddate, long days, int batch, char
*ext_sect, CONF *conf,
    int verbose, unsigned long certopt, unsigned long
nameopt,
    int default_op, int ext_copy, int selfsign);
 static int certify_cert(X509 **xret, char *infile,EVP_PKEY *pkey,X509
*x509,
  const EVP_MD *dgst,STACK_OF(CONF_VALUE)
*policy,
- CA_DB *db, BIGNUM *serial, char *subj, int
multirdn, int email_dn,
+ CA_DB *db, BIGNUM *serial, char *subj,unsigned
long chtype, int multirdn, int email_dn,
  char *startdate, char *enddate, long days, int
batch,
  char *ext_sect, CONF *conf,int verbose,
unsigned long certopt,
  unsigned long nameopt, int default_op, int
ext_copy,
  ENGINE *e);
 static int certify_spkac(X509 **xret, char *infile,EVP_PKEY
*pkey,X509 *x509,
  const EVP_MD *dgst,STACK_OF(CONF_VALUE)
*policy,
- CA_DB *db, BIGNUM *serial,char *subj, int
multirdn, int email_dn,
+ CA_DB *db, BIGNUM *serial,char *subj,unsigned
long chtype, int multirdn, int email_dn,
  char *startdate, char *enddate, long days,
char *ext_sect,
  CONF *conf, int verbose, unsigned long
certopt,
  unsigned long nameopt, int default_op, int
ext_copy);
 static int fix_data(int nid, int *type);
 static void write_new_certificate(BIO *bp, X509 *x, int output_der,
int notext);
 static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, const
EVP_MD *dgst,
- STACK_OF(CONF_VALUE) *policy, CA_DB *db, BIGNUM *serial,char
*subj, int multirdn,
+ STACK_OF(CONF_VALUE) *policy, CA_DB *db, BIGNUM *serial,char
*subj,unsigned long chtype, int multirdn,
  int email_dn, char *startdate, char *enddate, long days, int
batch,
        int verbose, X509_REQ *req, char *ext_sect, CONF *conf,
  unsigned long certopt, unsigned long nameopt, int default_op,
@@ -275,6 +275,7 @@
  char *extensions=NULL;
  char *extfile=NULL;
  char *subj=NULL;
+ unsigned long chtype = MBSTRING_ASC;
  int multirdn = 0;
  char *tmp_email_dn=NULL;
  char *crl_ext=NULL;
@@ -356,6 +357,8 @@
  subj= *(++argv);
  /* preserve=1; */
  }
+ else if (strcmp(*argv,"-utf8") == 0)
+ chtype = MBSTRING_UTF8;
  else if (strcmp(*argv,"-create_serial") == 0)
  create_ser = 1;
  else if (strcmp(*argv,"-multivalue-rdn") == 0)
@@ -645,6 +648,13 @@
  ERR_clear_error();
  app_RAND_load_file(randfile, bio_err, 0);
 
+ if (chtype == MBSTRING_UTF8){
+ if( !ASN1_STRING_set_default_mask_asc("utf8only")) {
+ BIO_printf(bio_err, "Invalid global string
mask setting %s\n", "utf8only" );
+ goto err;
+ }
+ }
+
  db_attr.unique_subject = 1;
  p = NCONF_get_string(conf, section, ENV_UNIQUE_SUBJECT);
  if (p)
@@ -1135,7 +1145,7 @@
  {
  total++;
  j=certify_spkac
(&x,spkac_file,pkey,x509,dgst,attribs,db,
-
        serial,subj,multirdn,email_dn,startdate,enddate,days,extensions
,
+
        serial,subj,chtype,multirdn,email_dn,startdate,enddate,days,ext
ensions,
 
        conf,verbose,certopt,nameopt,default_op,ext_copy);
  if (j < 0) goto err;
  if (j > 0)
@@ -1159,7 +1169,7 @@
  {
  total++;
  j=certify_cert
(&x,ss_cert_file,pkey,x509,dgst,attribs,
-
        db,serial,subj,multirdn,email_dn,startdate,enddate,days,batch,
+
        db,serial,subj,chtype,multirdn,email_dn,startdate,enddate,days,
batch,
  extensions,conf,verbose, certopt,
nameopt,
  default_op, ext_copy, e);
  if (j < 0) goto err;
@@ -1179,7 +1189,7 @@
  {
  total++;
  j=certify(&x,infile,pkey,x509p,dgst,attribs,db,
-
        serial,subj,multirdn,email_dn,startdate,enddate,days,batch,
+
        serial,subj,chtype,multirdn,email_dn,startdate,enddate,days,bat
ch,
  extensions,conf,verbose, certopt,
nameopt,
  default_op, ext_copy, selfsign);
  if (j < 0) goto err;
@@ -1199,7 +1209,7 @@
  {
  total++;
  j=certify(&x,argv
[i],pkey,x509p,dgst,attribs,db,
-
        serial,subj,multirdn,email_dn,startdate,enddate,days,batch,
+
        serial,subj,chtype,multirdn,email_dn,startdate,enddate,days,bat
ch,
  extensions,conf,verbose, certopt,
nameopt,
  default_op, ext_copy, selfsign);
  if (j < 0) goto err;
@@ -1509,7 +1519,7 @@
 
 static int certify(X509 **xret, char *infile, EVP_PKEY *pkey, X509
*x509,
      const EVP_MD *dgst, STACK_OF(CONF_VALUE) *policy, CA_DB
*db,
-     BIGNUM *serial, char *subj, int multirdn, int email_dn,
char *startdate, char *enddate,
+     BIGNUM *serial, char *subj,unsigned long chtype, int
multirdn, int email_dn, char *startdate, char *enddate,
      long days, int batch, char *ext_sect, CONF *lconf, int
verbose,
      unsigned long certopt, unsigned long nameopt, int
default_op,
      int ext_copy, int selfsign)
@@ -1565,7 +1575,7 @@
  else
  BIO_printf(bio_err,"Signature ok\n");
 
- ok=do_body(xret,pkey,x509,dgst,policy,db,serial,subj,
multirdn, email_dn,
+ ok=do_body
(xret,pkey,x509,dgst,policy,db,serial,subj,chtype,multirdn, email_dn,
 
        startdate,enddate,days,batch,verbose,req,ext_sect,lconf,
  certopt, nameopt, default_op, ext_copy, selfsign);
 
@@ -1577,7 +1587,7 @@
 
 static int certify_cert(X509 **xret, char *infile, EVP_PKEY *pkey,
X509 *x509,
      const EVP_MD *dgst, STACK_OF(CONF_VALUE) *policy, CA_DB
*db,
-     BIGNUM *serial, char *subj, int multirdn, int email_dn,
char *startdate, char *enddate,
+     BIGNUM *serial, char *subj, unsigned long chtype, int
multirdn, int email_dn, char *startdate, char *enddate,
      long days, int batch, char *ext_sect, CONF *lconf, int
verbose,
      unsigned long certopt, unsigned long nameopt, int
default_op,
      int ext_copy, ENGINE *e)
@@ -1619,7 +1629,7 @@
  if ((rreq=X509_to_X509_REQ(req,NULL,EVP_md5())) == NULL)
  goto err;
 
- ok=do_body
(xret,pkey,x509,dgst,policy,db,serial,subj,multirdn,email_dn,startdate,
enddate,
+ ok=do_body
(xret,pkey,x509,dgst,policy,db,serial,subj,chtype,multirdn,email_dn,sta
rtdate,enddate,
  days,batch,verbose,rreq,ext_sect,lconf, certopt,
nameopt, default_op,
  ext_copy, 0);
 
@@ -1631,7 +1641,7 @@
 
 static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, const
EVP_MD *dgst,
      STACK_OF(CONF_VALUE) *policy, CA_DB *db, BIGNUM *serial,
char *subj,
-     int multirdn,
+     unsigned long chtype, int multirdn,
      int email_dn, char *startdate, char *enddate, long days,
int batch,
      int verbose, X509_REQ *req, char *ext_sect, CONF *lconf,
      unsigned long certopt, unsigned long nameopt, int
default_op,
@@ -1664,7 +1674,7 @@
 
  if (subj)
  {
- X509_NAME *n = parse_name(subj, MBSTRING_ASC,
multirdn);
+ X509_NAME *n = parse_name(subj, chtype, multirdn);
 
  if (!n)
  {
@@ -2201,7 +2211,7 @@
 
 static int certify_spkac(X509 **xret, char *infile, EVP_PKEY *pkey,
X509 *x509,
      const EVP_MD *dgst, STACK_OF(CONF_VALUE) *policy, CA_DB
*db,
-     BIGNUM *serial, char *subj, int multirdn, int email_dn,
char *startdate, char *enddate,
+     BIGNUM *serial, char *subj,unsigned long chtype, int
multirdn, int email_dn, char *startdate, char *enddate,
      long days, char *ext_sect, CONF *lconf, int verbose,
unsigned long certopt,
      unsigned long nameopt, int default_op, int ext_copy)
  {
@@ -2342,7 +2352,7 @@
 
  X509_REQ_set_pubkey(req,pktmp);
  EVP_PKEY_free(pktmp);
- ok=do_body
(xret,pkey,x509,dgst,policy,db,serial,subj,multirdn,email_dn,startdate,
enddate,
+ ok=do_body
(xret,pkey,x509,dgst,policy,db,serial,subj,chtype,multirdn,email_dn,sta
rtdate,enddate,
    days,1,verbose,req,ext_sect,lconf, certopt,
nameopt, default_op,
  ext_copy, 0);
 err:
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [hidden email]
Automated List Manager                           [hidden email]