1.\" $OpenBSD: X509_REQ_print_ex.3,v 1.2 2021/11/19 15:50:46 schwarze Exp $
2.\"
3.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: November 19 2021 $
18.Dt X509_REQ_PRINT_EX 3
19.Os
20.Sh NAME
21.Nm X509_REQ_print_ex ,
22.Nm X509_REQ_print ,
23.Nm X509_REQ_print_fp
24.Nd pretty-print a PKCS#10 certification request
25.Sh SYNOPSIS
26.Ft int
27.Fo X509_REQ_print_ex
28.Fa "BIO *bio"
29.Fa "X509_REQ *req"
30.Fa "unsigned long nameflags"
31.Fa "unsigned long skipflags"
32.Fc
33.Ft int
34.Fo X509_REQ_print
35.Fa "BIO *bio"
36.Fa "X509_REQ *req"
37.Fc
38.Ft int
39.Fo X509_REQ_print_fp
40.Fa "FILE *fp"
41.Fa "X509_REQ *req"
42.Fc
43.Sh DESCRIPTION
44.Fn X509_REQ_print_ex
45prints information contained in
46.Fa req
47to
48.Fa bio
49in human-readable form.
50Printing is aborted as soon as any operation fails, with the exception
51that failures while attempting to decode or print the public key
52are not considered as errors.
53.Pp
54By default, the following blocks of information
55are printed in the following order.
56Each block can be skipped by setting the corresponding bit in
57.Fa skipflags ,
58provided in parentheses after each block description.
59.Bl -bullet
60.It
61A pair of lines reading
62.Qq Certificate Request:\&
63and
64.Qq Data:\&
65containing no information.
66.Pq Dv X509_FLAG_NO_HEADER
67.It
68The value contained in the version field
69in decimal and hexadecimal notation.
70.Pq Dv X509_FLAG_NO_VERSION
71.It
72The subject name is printed with
73.Xr X509_NAME_print_ex 3 .
74.Pq Dv X509_FLAG_NO_SUBJECT
75.It
76The public key algorithm is printed with
77.Xr i2a_ASN1_OBJECT 3 ,
78and the public key returned from
79.Xr X509_REQ_get_pubkey 3
80with
81.Xr EVP_PKEY_print_public 3 .
82.Pq Dv X509_FLAG_NO_PUBKEY
83.It
84For each X.501 attribute that is not a requested extension according to
85.Xr X509_REQ_extension_nid 3 ,
86the object identifier is printed with
87.Xr i2a_ASN1_OBJECT 3 ,
88and all values of the types
89.Dv V_ASN1_PRINTABLESTRING ,
90.Dv V_ASN1_T61STRING ,
91and
92.Dv V_ASN1_IA5STRING
93are printed with
94.Xr BIO_write 3 .
95.Pq Dv X509_FLAG_NO_ATTRIBUTES
96.It
97The requested extensions are retrieved with
98.Xr X509_REQ_get_extensions 3
99and their types and values are printed with
100.Xr i2a_ASN1_OBJECT 3
101and
102.Xr X509V3_EXT_print 3 ,
103or, if the latter fails, with
104.Xr ASN1_STRING_print 3 .
105.Pq Dv X509_FLAG_NO_EXTENSIONS
106.It
107The signature is printed with
108.Xr X509_signature_print 3 .
109.Pq Dv X509_FLAG_NO_SIGDUMP
110.El
111.Pp
112The
113.Fa nameflags
114argument modifies the format for printing X.501
115.Vt Name
116objects contained in
117.Fa req .
118It is passed through to
119.Xr X509_NAME_print_ex 3 .
120If
121.Fa nameflags
122is
123.Dv X509_FLAG_COMPAT ,
124the
125.Fa indent
126argument of
127.Xr X509_NAME_print_ex 3
128is set to 16 spaces and the traditional SSLeay format generated by
129.Xr X509_NAME_print 3
130is used.
131Otherwise, if the only bit set in
132.Dv XN_FLAG_SEP_MASK
133is
134.Dv XN_FLAG_SEP_MULTILINE ,
135.Fa indent
136is set to 12 spaces.
137Otherwise, indent is set to zero.
138.Pp
139.Fn X509_REQ_print
140is a wrapper function setting the
141.Fa nameflags
142to
143.Dv XN_FLAG_COMPAT
144and the
145.Fa skipflags
146to
147.Dv X509_FLAG_COMPAT .
148.Pp
149.Fn X509_REQ_print_fp
150is similar to
151.Fn X509_REQ_print
152except that it prints to
153.Fa fp .
154.Sh RETURN VALUES
155These functions return 1 if all requested information was successfully
156printed, even if failures occurred while attempting to decode or
157print the public key, or 0 if any operation fails.
158.Sh SEE ALSO
159.Xr BIO_new 3 ,
160.Xr X509_print_ex 3 ,
161.Xr X509_REQ_new 3
162.Sh HISTORY
163.Fn X509_REQ_print
164first appeared in SSLeay 0.4.4 and
165.Fn X509_REQ_print_fp
166in SSLeay 0.6.0.
167These functions have been available since
168.Ox 2.4 .
169.Pp
170.Fn X509_REQ_print_ex
171first appeared in OpenSSL 0.9.7 and has been available since
172.Ox 3.2 .
173.Sh BUGS
174Some printing failures are silently ignored while printing extensions,
175which may result in incomplete data being printed.
176