#include <openssl/x509.h>
#include <openssl/buffer.h>
#include "crypto/x509.h"
+#include "crypto/ctype.h"
DEFINE_STACK_OF(X509_NAME_ENTRY)
const X509_NAME_ENTRY *ne;
int i;
int n, lold, l, l1, l2, num, j, type;
+ int prev_set = -1;
const char *s;
char *p;
unsigned char *q;
if (!gs_doit[j & 3])
continue;
l2++;
-#ifndef CHARSET_EBCDIC
- if ((q[j] < ' ') || (q[j] > '~'))
- l2 += 3;
-#else
- if ((os_toascii[q[j]] < os_toascii[' ']) ||
- (os_toascii[q[j]] > os_toascii['~']))
+ if (q[j] == '/' || q[j] == '+')
+ l2++; /* char needs to be escaped */
+ else if ((ossl_toascii(q[j]) < ossl_toascii(' ')) ||
+ (ossl_toascii(q[j]) > ossl_toascii('~')))
l2 += 3;
-#endif
}
lold = l;
break;
} else
p = &(buf[lold]);
- *(p++) = '/';
+ *(p++) = prev_set == ne->set ? '+' : '/';
memcpy(p, s, (unsigned int)l1);
p += l1;
*(p++) = '=';
*(p++) = 'x';
*(p++) = hex[(n >> 4) & 0x0f];
*(p++) = hex[n & 0x0f];
- } else
+ } else {
+ if (n == '/' || n == '+')
+ *(p++) = '\\';
*(p++) = n;
+ }
#else
n = os_toascii[q[j]];
if ((n < os_toascii[' ']) || (n > os_toascii['~'])) {
*(p++) = 'x';
*(p++) = hex[(n >> 4) & 0x0f];
*(p++) = hex[n & 0x0f];
- } else
+ } else {
+ if (n == os_toascii['/'] || n == os_toascii['+'])
+ *(p++) = '\\';
*(p++) = q[j];
+ }
#endif
}
*p = '\0';
+ prev_set = ne->set;
}
if (b != NULL) {
p = b->data;
=head1 DESCRIPTION
-X509_NAME_print_ex() prints a human readable version of B<nm> to BIO B<out>.
-Each line (for multiline formats) is indented by B<indent> spaces. The
-output format can be extensively customised by use of the B<flags> parameter.
+X509_NAME_print_ex() prints a human readable version of I<nm> to BIO I<out>.
+Each line (for multiline formats) is indented by I<indent> spaces. The
+output format can be extensively customised by use of the I<flags> parameter.
X509_NAME_print_ex_fp() is identical to X509_NAME_print_ex()
-except the output is written to FILE pointer B<fp>.
+except the output is written to FILE pointer I<fp>.
-X509_NAME_oneline() prints an ASCII version of B<a> to B<buf>.
-If B<buf> is B<NULL> then a buffer is dynamically allocated and returned, and
-B<size> is ignored.
-Otherwise, at most B<size> bytes will be written, including the ending '\0',
-and B<buf> is returned.
+X509_NAME_oneline() prints an ASCII version of I<a> to I<buf>.
+This supports multi-valued RDNs and escapes B</> and B<+> characters in values.
+If I<buf> is B<NULL> then a buffer is dynamically allocated and returned, and
+I<size> is ignored.
+Otherwise, at most I<size> bytes will be written, including the ending '\0',
+and I<buf> is returned.
-X509_NAME_print() prints out B<name> to B<bp> indenting each line by B<obase>
+X509_NAME_print() prints out I<name> to I<bp> indenting each line by I<obase>
characters. Multiple lines are used if the output (including indent) exceeds
80 characters.
=head1 NOTES
The functions X509_NAME_oneline() and X509_NAME_print()
-produce a non standard output form, they don't handle multi character fields and
+produce a non standard output form, they don't handle multi-character fields and
have various quirks and inconsistencies.
Their use is strongly discouraged in new applications and they could
be deprecated in a future release.