aboutsummaryrefslogtreecommitdiffstats
path: root/apps/apps.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2000-07-28 01:58:15 +0000
committerDr. Stephen Henson <steve@openssl.org>2000-07-28 01:58:15 +0000
commita657546f9c376f4b7ba4dce14649598fb1a38de5 (patch)
tree57869397b334bf1d3f3e756d48d73248946f9039 /apps/apps.c
parent8083e1bd9e2bc7d32cee960c09dcb838c12a0495 (diff)
downloadopenssl-a657546f9c376f4b7ba4dce14649598fb1a38de5.tar.gz
New ASN1_STRING_print_ex() and X509_NAME_print_ex()
functions. These are intended to be replacements for the ancient ASN1_STRING_print() and X509_NAME_print() functions. The new functions support RFC2253 and various pretty printing options. It is also possible to display international characters if the terminal properly handles UTF8 encoding (Linux seems to tolerate this if the "unicode_start" script is run). Still needs to be documented, integrated into other utilities and extensively tested.
Diffstat (limited to 'apps/apps.c')
-rw-r--r--apps/apps.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/apps/apps.c b/apps/apps.c
index 0781c4bf93..183a2b1d8a 100644
--- a/apps/apps.c
+++ b/apps/apps.c
@@ -653,3 +653,83 @@ end:
return(othercerts);
}
+typedef struct {
+ char *name;
+ unsigned long flag;
+ unsigned long mask;
+} NAME_EX_TBL;
+
+int set_name_ex(unsigned long *flags, const char *arg)
+{
+ char c;
+ const NAME_EX_TBL *ptbl, ex_tbl[] = {
+ { "esc_2253", ASN1_STRFLGS_ESC_2253, 0},
+ { "esc_ctrl", ASN1_STRFLGS_ESC_CTRL, 0},
+ { "esc_msb", ASN1_STRFLGS_ESC_MSB, 0},
+ { "use_quote", ASN1_STRFLGS_ESC_QUOTE, 0},
+ { "utf8", ASN1_STRFLGS_UTF8_CONVERT, 0},
+ { "no_type", ASN1_STRFLGS_IGNORE_TYPE, 0},
+ { "show_name", ASN1_STRFLGS_SHOW_NAME, 0},
+ { "dump_all", ASN1_STRFLGS_DUMP_ALL, 0},
+ { "dump_nostr", ASN1_STRFLGS_DUMP_UNKNOWN, 0},
+ { "dump_der", ASN1_STRFLGS_DUMP_DER, 0},
+ { "compat", XN_FLAG_COMPAT, 0xffffffffL},
+ { "sep_comma_plus", XN_FLAG_SEP_COMMA_PLUS, XN_FLAG_SEP_MASK},
+ { "sep_comma_plus_space", XN_FLAG_SEP_CPLUS_SPC, XN_FLAG_SEP_MASK},
+ { "sep_semi_plus_space", XN_FLAG_SEP_SPLUS_SPC, XN_FLAG_SEP_MASK},
+ { "sep_multiline", XN_FLAG_SEP_MULTILINE, XN_FLAG_SEP_MASK},
+ { "dn_rev", XN_FLAG_DN_REV, 0},
+ { "nofname", XN_FLAG_FN_NONE, XN_FLAG_FN_MASK},
+ { "sname", XN_FLAG_FN_SN, XN_FLAG_FN_MASK},
+ { "lname", XN_FLAG_FN_LN, XN_FLAG_FN_MASK},
+ { "oid", XN_FLAG_FN_OID, XN_FLAG_FN_MASK},
+ { "space_eq", XN_FLAG_SPC_EQ, 0},
+ { "dump_unknown", XN_FLAG_DUMP_UNKNOWN_FIELDS, 0},
+ { "RFC2253", XN_FLAG_RFC2253, 0xffffffffL},
+ { "oneline", XN_FLAG_ONELINE, 0xffffffffL},
+ { "multiline", XN_FLAG_MULTILINE, 0xffffffffL},
+ { NULL, 0, 0}
+ };
+
+ c = arg[0];
+
+ if(c == '-') {
+ c = 0;
+ arg++;
+ } else if (c == '+') {
+ c = 1;
+ arg++;
+ } else c = 1;
+
+ for(ptbl = ex_tbl; ptbl->name; ptbl++) {
+ if(!strcmp(arg, ptbl->name)) {
+ *flags &= ~ptbl->mask;
+ if(c) *flags |= ptbl->flag;
+ else *flags &= ~ptbl->flag;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+void print_name(BIO *out, char *title, X509_NAME *nm, unsigned long lflags)
+{
+ char buf[256];
+ char mline = 0;
+ int indent = 0;
+ if(title) BIO_puts(out, title);
+ if((lflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) {
+ mline = 1;
+ indent = 4;
+ }
+ if(lflags == XN_FLAG_COMPAT) {
+ X509_NAME_oneline(nm,buf,256);
+ BIO_puts(out,buf);
+ BIO_puts(out, "\n");
+ } else {
+ if(mline) BIO_puts(out, "\n");
+ X509_NAME_print_ex(out, nm, indent, lflags);
+ BIO_puts(out, "\n");
+ }
+}
+