1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
.\" $OpenBSD: X509_REQ_add_extensions.3,v 1.1 2021/10/27 14:54:07 schwarze Exp $
.\"
.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: October 27 2021 $
.Dt X509_REQ_ADD_EXTENSIONS 3
.Os
.Sh NAME
.Nm X509_REQ_add_extensions ,
.Nm X509_REQ_add_extensions_nid ,
.Nm X509_REQ_get_extensions ,
.Nm X509_REQ_set_extension_nids ,
.Nm X509_REQ_get_extension_nids ,
.Nm X509_REQ_extension_nid
.Nd extensions in certification requests
.Sh SYNOPSIS
.In openssl/x509.h
.Ft int
.Fo X509_REQ_add_extensions
.Fa "X509_REQ *req"
.Fa "STACK_OF(X509_EXTENSION) *extensions"
.Fc
.Ft int
.Fo X509_REQ_add_extensions_nid
.Fa "X509_REQ *req"
.Fa "STACK_OF(X509_EXTENSION) *extensions"
.Fa "int nid"
.Fc
.Ft STACK_OF(X509_EXTENSION) *
.Fn X509_REQ_get_extensions "X509_REQ *req"
.Ft void
.Fn X509_REQ_set_extension_nids "int *nids"
.Ft int *
.Fn X509_REQ_get_extension_nids void
.Ft int
.Fn X509_REQ_extension_nid "int nid"
.Sh DESCRIPTION
.Fn X509_REQ_add_extensions
encodes the array of
.Fa extensions
using
.Xr i2d_X509_EXTENSIONS 3
and adds a new X.501 Attribute object of the type
.Dv NID_ext_req
to
.Fa req
using the equivalent of
.Xr X509_ATTRIBUTE_create_by_NID 3
with a
.Fa type
of
.Dv V_ASN1_SEQUENCE .
.Pp
.Fn X509_REQ_add_extensions_nid
is identical except that the specified
.Fa nid
is used as the X.501 Attribute type instead of
.Dv NID_ext_req .
.Pp
.Fn X509_REQ_get_extensions
retrieves the first value of the first X.501 Attribute of appropriate type.
By default, the attribute types
.Dv NID_ext_req
and
.Dv NID_ms_ext_req
are considered appropriate.
.Pp
.Fn X509_REQ_set_extension_nids
replaces the list of attribute types that
.Fn X509_REQ_get_extensions
considers appropriate for storing extensions.
The
.Fa nids
argument is interpreted as a pointer to the first element
of a variable-sized array of
.Vt int .
The last element of the array has to be
.Dv NID_undef .
The array needs to remain valid until
.Fn X509_REQ_set_extension_nids
is called again with a different argument.
.Pp
.Fn X509_REQ_extension_nid
checks whether
.Fn X509_REQ_get_extensions
regards the
.Fa nid
argument as a type appropriate for storing extensions.
.Sh RETURN VALUES
.Fn X509_REQ_add_extensions
and
.Fn X509_REQ_add_extensions_nid
returns 1 for success or 0 for failure.
.Pp
.Fn X509_REQ_get_extensions
returns a newly allocated array of ASN.1
.Vt Extension
objects or
.Dv NULL
if
.Fa req
is
.Dv NULL ,
does not contain
.Vt CertificationRequestInfo ,
contains no attribute of an appropriate type,
or if decoding or memory allocation fails.
.Pp
.Fn X509_REQ_get_extension_nids
returns the pointer installed with
.Fn X509_REQ_set_extension_nids
or a pointer to a static array
.Brq Dv NID_ext_req , NID_ms_ext_req , NID_undef
by default.
.Pp
.Fn X509_REQ_extension_nid
returns 1 if
.Fa nid
is considered appropriate or 0 otherwise.
.Sh SEE ALSO
.Xr d2i_X509_EXTENSION 3 ,
.Xr STACK_OF 3 ,
.Xr X509_EXTENSION_new 3 ,
.Xr X509_REQ_new 3 ,
.Xr X509V3_extensions_print 3
.Sh HISTORY
These functions first appeared in OpenSSL 0.9.5
and have been available since
.Ox 2.7 .
|