summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschwarze <>2021-07-25 14:05:03 +0000
committerschwarze <>2021-07-25 14:05:03 +0000
commit33ebe6f37b9fdb4bc9eb04dfa95da59ed59d9427 (patch)
tree1e1edab23798732565aa9aef3339af86913861ce
parent8e08483ba2fdedb74220d07afd52742b7e8af6bc (diff)
downloadopenbsd-33ebe6f37b9fdb4bc9eb04dfa95da59ed59d9427.tar.gz
openbsd-33ebe6f37b9fdb4bc9eb04dfa95da59ed59d9427.tar.bz2
openbsd-33ebe6f37b9fdb4bc9eb04dfa95da59ed59d9427.zip
Document X509_STORE_CTX_set_trust(3), X509_STORE_CTX_set_purpose(3),
and X509_STORE_CTX_purpose_inherit(3). These functions look deceptively simple on first sight, but their semantics is surprisingly complicated.
-rw-r--r--src/lib/libcrypto/man/X509_STORE_CTX_set_flags.3230
1 files changed, 226 insertions, 4 deletions
diff --git a/src/lib/libcrypto/man/X509_STORE_CTX_set_flags.3 b/src/lib/libcrypto/man/X509_STORE_CTX_set_flags.3
index d84b1e7ae4..7247927385 100644
--- a/src/lib/libcrypto/man/X509_STORE_CTX_set_flags.3
+++ b/src/lib/libcrypto/man/X509_STORE_CTX_set_flags.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: X509_STORE_CTX_set_flags.3,v 1.2 2021/07/22 19:44:30 schwarze Exp $ 1.\" $OpenBSD: X509_STORE_CTX_set_flags.3,v 1.3 2021/07/25 14:05:03 schwarze Exp $
2.\" full merge up to: OpenSSL aae41f8c Jun 25 09:47:15 2015 +0100 2.\" full merge up to: OpenSSL aae41f8c Jun 25 09:47:15 2015 +0100
3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100 3.\" selective merge up to: OpenSSL 24a535ea Sep 22 13:14:20 2020 +0100
4.\" 4.\"
@@ -67,13 +67,16 @@
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE. 68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\" 69.\"
70.Dd $Mdocdate: July 22 2021 $ 70.Dd $Mdocdate: July 25 2021 $
71.Dt X509_STORE_CTX_SET_FLAGS 3 71.Dt X509_STORE_CTX_SET_FLAGS 3
72.Os 72.Os
73.Sh NAME 73.Sh NAME
74.Nm X509_STORE_CTX_set_flags , 74.Nm X509_STORE_CTX_set_flags ,
75.Nm X509_STORE_CTX_set_time , 75.Nm X509_STORE_CTX_set_time ,
76.Nm X509_STORE_CTX_set_depth , 76.Nm X509_STORE_CTX_set_depth ,
77.Nm X509_STORE_CTX_set_trust ,
78.Nm X509_STORE_CTX_set_purpose ,
79.Nm X509_STORE_CTX_purpose_inherit ,
77.Nm X509_STORE_CTX_get0_param , 80.Nm X509_STORE_CTX_get0_param ,
78.Nm X509_STORE_CTX_set0_param , 81.Nm X509_STORE_CTX_set0_param ,
79.Nm X509_STORE_CTX_set_default 82.Nm X509_STORE_CTX_set_default
@@ -96,6 +99,23 @@
96.Fa "X509_STORE_CTX *ctx" 99.Fa "X509_STORE_CTX *ctx"
97.Fa "int depth" 100.Fa "int depth"
98.Fc 101.Fc
102.Ft int
103.Fo X509_STORE_CTX_set_trust
104.Fa "X509_STORE_CTX *ctx"
105.Fa "int trust"
106.Fc
107.Ft int
108.Fo X509_STORE_CTX_set_purpose
109.Fa "X509_STORE_CTX *ctx"
110.Fa "int purpose"
111.Fc
112.Ft int
113.Fo X509_STORE_CTX_purpose_inherit
114.Fa "X509_STORE_CTX *ctx"
115.Fa "int def_purpose"
116.Fa "int purpose"
117.Fa "int trust"
118.Fc
99.Ft X509_VERIFY_PARAM * 119.Ft X509_VERIFY_PARAM *
100.Fo X509_STORE_CTX_get0_param 120.Fo X509_STORE_CTX_get0_param
101.Fa "X509_STORE_CTX *ctx" 121.Fa "X509_STORE_CTX *ctx"
@@ -132,17 +152,122 @@ for a description of the verification flags.
132.Pp 152.Pp
133.Fn X509_STORE_CTX_set_time 153.Fn X509_STORE_CTX_set_time
134sets the verification 154sets the verification
135.Fa time . 155.Fa time
156using
157.Xr X509_VERIFY_PARAM_set_time 3 .
136The 158The
137.Fa dummy 159.Fa dummy
138argument is ignored. 160argument is ignored.
139.Pp 161.Pp
140.Fn X509_STORE_CTX_set_depth 162.Fn X509_STORE_CTX_set_depth
141sets the maximum verification 163sets the maximum verification
142.Fa depth . 164.Fa depth
165using
166.Xr X509_VERIFY_PARAM_set_depth 3 .
143That is the maximum number of untrusted CA certificates 167That is the maximum number of untrusted CA certificates
144that can appear in a chain. 168that can appear in a chain.
145.Pp 169.Pp
170.Fn X509_STORE_CTX_set_trust
171sets the
172.Fa trust
173identifier that can also be set using
174.Xr X509_VERIFY_PARAM_set_trust 3 .
175If the
176.Fa trust
177argument is 0 or invalid
178or the trust identifier is already set to a non-zero value in the
179.Vt X509_VERIFY_PARAM
180object, no action occurs.
181Here and in the following,
182.Dv X509_TRUST_DEFAULT
183counts as invalid.
184.Pp
185.Fn X509_STORE_CTX_set_purpose
186sets the
187.Fa purpose
188identifier that can also be set using
189.Xr X509_VERIFY_PARAM_set_purpose 3 .
190If the
191.Fa purpose
192argument is 0 or any failure occurs, nothing is changed.
193.Pp
194In the following, the trust identifier contained in the
195.Vt X509_PURPOSE
196object associated with
197.Fa purpose
198is called the
199.Dq associated trust .
200.Pp
201The function fails if the
202.Fa purpose
203argument or the associated trust is not 0 but invalid; otherwise,
204.Fn X509_STORE_CTX_set_purpose
205also does the equivalent of calling
206.Fn X509_STORE_CTX_set_trust
207with the associated trust.
208.Pp
209If the purpose identifier is already set to a non-zero value in the
210.Vt X509_VERIFY_PARAM
211object, it is not changed, even if the
212.Fa purpose
213argument is valid, too.
214.Pp
215.Fn X509_STORE_CTX_purpose_inherit
216is similar to
217.Fn X509_STORE_CTX_set_purpose ,
218with the following modifications:
219.Bl -bullet
220.It
221If the
222.Fa purpose
223argument is 0,
224.Fa def_purpose
225is used instead.
226.It
227If the associated trust is
228.Dv X509_TRUST_DEFAULT ,
229the trust associated with
230.Fa def_purpose
231is used instead, or if
232.Fa def_purpose
233is 0 or invalid, the function fails.
234.It
235If the
236.Fa trust
237argument is not 0, it is used instead of the associated trust,
238and the equivalent of calling
239.Fn X509_STORE_CTX_set_trust
240is done even if both
241.Fa purpose
242and
243.Fa def_purpose
244are 0.
245Even if the
246.Fa trust
247argument is not 0, if the (then unused) associated trust is
248.Dv X509_TRUST_DEFAULT ,
249.Fa def_purpose
250is still required to be valid.
251.El
252.Pp
253Note that, even if all arguments are valid and the return value is 1,
254it is possible that nothing changed, or that only either one of the
255purpose and trust identifiers were set, or that both were set.
256It can also happen that the purpose identifier gets set according to the
257.Fa purpose
258argument, but the trust identifier gets set according to the
259.Fa def_purpose
260argument in the same call.
261.Pp
262The intended way of using this function is to pass the purpose and
263trust attributes of another structure of an arbitrary type as the
264.Fa purpose
265and
266.Fa trust
267arguments, and to provide
268.Fa def_purpose
269as a fallback in case the settings in the other structure are incomplete.
270.Pp
146.Fn X509_STORE_CTX_get0_param 271.Fn X509_STORE_CTX_get0_param
147retrieves an internal pointer to the verification parameters associated 272retrieves an internal pointer to the verification parameters associated
148with 273with
@@ -163,6 +288,61 @@ This uses the function
163to find an appropriate set of parameters from 288to find an appropriate set of parameters from
164.Fa name . 289.Fa name .
165.Sh RETURN VALUES 290.Sh RETURN VALUES
291.Fn X509_STORE_CTX_set_trust
292returns 1 if the
293.Fa trust
294argument is 0 or valid or 0 if it is not 0 but invalid.
295A return value of 1 does
296.Em not
297imply that the trust identifier stored in the
298.Vt X509_VERIFY_PARAM
299object was changed.
300.Pp
301.Fn X509_STORE_CTX_set_purpose
302returns 1 if both the
303.Fa purpose
304argument and the associated trust are 0 or valid.
305It returns 0 if either the
306.Fa purpose
307argument or the associated trust is not 0 but invalid.
308A return value of 1 does not imply that any data was changed.
309.Pp
310.Fn X509_STORE_CTX_purpose_inherit
311returns 0 if:
312.Bl -bullet
313.It
314The
315.Fa purpose
316argument is not 0 and invalid.
317.It
318The
319.Fa purpose
320argument is 0 and the
321.Fa def_purpose
322argument is not 0 and invalid.
323.It
324The associated trust is
325.Dv X509_TRUST_DEFAULT
326and the
327.Fa def_purpose
328argument is 0 or invalid,
329or the trust identifier associated with it is not 0 but invalid.
330.It
331The
332.Fa trust
333argument is not 0 and invalid.
334.It
335The
336.Fa trust
337argument is 0 and the associated trust is neither 0 nor
338.Dv X509_TRUST_DEFAULT
339but invalid.
340.El
341.Pp
342Otherwise,
343.Fn X509_STORE_CTX_purpose_inherit
344returns 1, which does not imply that any data was changed.
345.Pp
166.Fn X509_STORE_CTX_get0_param 346.Fn X509_STORE_CTX_get0_param
167returns a pointer to an 347returns a pointer to an
168.Vt X509_VERIFY_PARAM 348.Vt X509_VERIFY_PARAM
@@ -172,6 +352,41 @@ if an error occurred.
172.Pp 352.Pp
173.Fn X509_STORE_CTX_set_default 353.Fn X509_STORE_CTX_set_default
174returns 1 for success or 0 if an error occurred. 354returns 1 for success or 0 if an error occurred.
355.Sh ERRORS
356For
357.Fn X509_STORE_CTX_set_trust ,
358.Fn X509_STORE_CTX_set_purpose ,
359and
360.Fn X509_STORE_CTX_purpose_inherit ,
361the following diagnostics can be retrieved with
362.Xr ERR_get_error 3 ,
363.Xr ERR_GET_REASON 3 ,
364and
365.Xr ERR_reason_error_string 3 :
366.Bl -tag -width Ds
367.It Dv X509_R_UNKNOWN_TRUST_ID Qq "unknown trust id"
368The
369.Fa trust
370argument or the trust identifier associated with
371.Fa purpose
372or
373.Fa def_purpose
374is not 0 but invalid,
375.It Dv X509_R_UNKNOWN_PURPOSE_ID Qq "unknown purpose id"
376The
377.Fa purpose
378argument is not 0 and invalid.
379Or it is 0 and the
380.Fa def_purpose
381argument is not 0 and invalid.
382Or the associated trust is
383.Dv X509_TRUST_DEFAULT
384and
385.Fa def_purpose
386is 0 or invalid.
387.El
388.Pp
389The other functions provide no diagnostics.
175.Sh SEE ALSO 390.Sh SEE ALSO
176.Xr X509_STORE_CTX_get_error 3 , 391.Xr X509_STORE_CTX_get_error 3 ,
177.Xr X509_STORE_CTX_new 3 , 392.Xr X509_STORE_CTX_new 3 ,
@@ -184,6 +399,13 @@ returns 1 for success or 0 if an error occurred.
184first appeared in OpenSSL 0.9.3 and has been available since 399first appeared in OpenSSL 0.9.3 and has been available since
185.Ox 2.4 . 400.Ox 2.4 .
186.Pp 401.Pp
402.Fn X509_STORE_CTX_set_trust ,
403.Fn X509_STORE_CTX_set_purpose ,
404and
405.Fn X509_STORE_CTX_purpose_inherit
406first appeared in OpenSSL 0.9.5 and have been available since
407.Ox 2.7 .
408.Pp
187.Fn X509_STORE_CTX_set_flags 409.Fn X509_STORE_CTX_set_flags
188and 410and
189.Fn X509_STORE_CTX_set_time 411.Fn X509_STORE_CTX_set_time