---
name: "libressl-X509_NAME_print_ex"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-X509_NAME_print_ex"
---

# libressl-X509\_NAME\_print\_ex(3)

X509\_NAME printing routines

## NAME

**X509\_NAME\_print\_ex**, **X509\_NAME\_print\_ex\_fp**, **X509\_NAME\_oneline** – X509\_NAME printing routines

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#include \<openssl/x509.h\>**

*int*\

**X509\_NAME\_print\_ex**(*BIO \*out*, *const X509\_NAME \*nm*, *int indent*, *unsigned long flags*);

*int*\

**X509\_NAME\_print\_ex\_fp**(*FILE \*fp*, *const X509\_NAME \*nm*, *int indent*, *unsigned long flags*);

*char* *\**\

**X509\_NAME\_oneline**(*const X509\_NAME \*a*, *char \*buf*, *int size*);

## DESCRIPTION

**X509\_NAME\_print\_ex**() prints a human readable version of *nm* to *BIO* *out*. Each line (for multiline formats) is indented by *indent* spaces. The output format can be extensively customised by use of the *flags* parameter.

**X509\_NAME\_print\_ex\_fp**() is identical to **X509\_NAME\_print\_ex**() except the output is written to the *FILE* pointer *fp*.

**X509\_NAME\_oneline**() prints an ASCII version of *a* to *buf*. If *buf* is NULL, then a buffer is dynamically allocated and returned, and *size* is ignored. Otherwise, at most *size* bytes will be written, including the ending NUL, and *buf* is returned.

**X509\_NAME\_oneline**() is a legacy function which produces a non-standard output form. It doesn't handle multi-character fields and has various quirks and inconsistencies. Its use is strongly discouraged in new applications.

Although there are a large number of possible flags, for most purposes XN\_FLAG\_ONELINE, XN\_FLAG\_MULTILINE, or XN\_FLAG\_RFC2253 will suffice. As noted on the ASN1\_STRING\_print\_ex(3) manual page, for UTF-8 terminals the ASN1\_STRFLGS\_ESC\_MSB should be unset: so for example XN\_FLAG\_ONELINE & ~ASN1\_STRFLGS\_ESC\_MSB would be used.

The complete set of the flags supported by X509\_NAME\_print\_ex is listed below.

Several options can be OR'ed together.

The options XN\_FLAG\_SEP\_COMMA\_PLUS, XN\_FLAG\_SEP\_CPLUS\_SPC, XN\_FLAG\_SEP\_SPLUS\_SPC, and XN\_FLAG\_SEP\_MULTILINE determine the field separators to use. Two distinct separators are used between distinct *RelativeDistinguishedName* components and separate values in the same RDN for a multi-valued RDN. Multi-valued RDNs are currently very rare so the second separator will hardly ever be used.

XN\_FLAG\_SEP\_COMMA\_PLUS uses comma and plus as separators. XN\_FLAG\_SEP\_CPLUS\_SPC uses comma and plus with spaces: this is more readable that plain comma and plus. XN\_FLAG\_SEP\_SPLUS\_SPC uses spaced semicolon and plus. XN\_FLAG\_SEP\_MULTILINE uses spaced newline and plus respectively. XN\_FLAG\_SEP\_MASK contains the bits used to represent these four options.

If XN\_FLAG\_DN\_REV is set, the whole DN is printed in reversed order.

The fields XN\_FLAG\_FN\_SN, XN\_FLAG\_FN\_LN, XN\_FLAG\_FN\_OID, and XN\_FLAG\_FN\_NONE determine how a field name is displayed. It will use the short name (e.g. CN), the long name (e.g. commonName), always use OID numerical form (normally OIDs are only used if the field name is not recognised) and no field name, respectively. XN\_FLAG\_FN\_MASK contains the bits used to represent these four options.

If XN\_FLAG\_SPC\_EQ is set, then spaces will be placed around the ‘=’ character separating field names and values.

If XN\_FLAG\_DUMP\_UNKNOWN\_FIELDS is set, then the encoding of unknown fields is printed instead of the values.

If XN\_FLAG\_FN\_ALIGN is set, then field names are padded to 20 characters: this is only of use for multiline format.

Additionally, all the options supported by ASN1\_STRING\_print\_ex(3) can be used to control how each field value is displayed.

In addition a number of options can be set for commonly used formats.

XN\_FLAG\_RFC2253 sets options which produce an output compatible with RFC 2253. It is equivalent to ASN1\_STRFLGS\_RFC2253 \| XN\_FLAG\_SEP\_COMMA\_PLUS \| XN\_FLAG\_DN\_REV \| XN\_FLAG\_FN\_SN \| XN\_FLAG\_DUMP\_UNKNOWN\_FIELDS.

XN\_FLAG\_ONELINE is a more readable one line format which is the same as: ASN1\_STRFLGS\_RFC2253 \| ASN1\_STRFLGS\_ESC\_QUOTE \| XN\_FLAG\_SEP\_CPLUS\_SPC \| XN\_FLAG\_SPC\_EQ \| XN\_FLAG\_FN\_SN.

XN\_FLAG\_MULTILINE is a multiline format which is the same as: ASN1\_STRFLGS\_ESC\_CTRL \| ASN1\_STRFLGS\_ESC\_MSB \| XN\_FLAG\_SEP\_MULTILINE \| XN\_FLAG\_SPC\_EQ \| XN\_FLAG\_FN\_LN \| XN\_FLAG\_FN\_ALIGN.

XN\_FLAG\_COMPAT uses the traditional non-standard SSLeay format.

## RETURN VALUES

**X509\_NAME\_print\_ex**() and **X509\_NAME\_print\_ex\_fp**() return 1 on success or 0 on error if XN\_FLAG\_COMPAT is set in *flags*. Otherwise, they return the number of printed bytes including the indentation or -1 on error.

**X509\_NAME\_oneline**() returns a valid string on success or NULL on error.

## SEE ALSO

ASN1\_STRING\_print\_ex(3), d2i\_X509\_NAME(3), X509\_NAME\_get\_index\_by\_NID(3), X509\_NAME\_new(3)

## HISTORY

**X509\_NAME\_oneline**() first appeared in SSLeay 0.5.1 and has been available since OpenBSD 2.4.

**X509\_NAME\_print\_ex**() and **X509\_NAME\_print\_ex\_fp**() first appeared in OpenSSL 0.9.6 and have been available since OpenBSD 2.9.
