diff options
author | schwarze <> | 2021-07-25 14:05:03 +0000 |
---|---|---|
committer | schwarze <> | 2021-07-25 14:05:03 +0000 |
commit | 33ebe6f37b9fdb4bc9eb04dfa95da59ed59d9427 (patch) | |
tree | 1e1edab23798732565aa9aef3339af86913861ce | |
parent | 8e08483ba2fdedb74220d07afd52742b7e8af6bc (diff) | |
download | openbsd-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.3 | 230 |
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 |
134 | sets the verification | 154 | sets the verification |
135 | .Fa time . | 155 | .Fa time |
156 | using | ||
157 | .Xr X509_VERIFY_PARAM_set_time 3 . | ||
136 | The | 158 | The |
137 | .Fa dummy | 159 | .Fa dummy |
138 | argument is ignored. | 160 | argument is ignored. |
139 | .Pp | 161 | .Pp |
140 | .Fn X509_STORE_CTX_set_depth | 162 | .Fn X509_STORE_CTX_set_depth |
141 | sets the maximum verification | 163 | sets the maximum verification |
142 | .Fa depth . | 164 | .Fa depth |
165 | using | ||
166 | .Xr X509_VERIFY_PARAM_set_depth 3 . | ||
143 | That is the maximum number of untrusted CA certificates | 167 | That is the maximum number of untrusted CA certificates |
144 | that can appear in a chain. | 168 | that can appear in a chain. |
145 | .Pp | 169 | .Pp |
170 | .Fn X509_STORE_CTX_set_trust | ||
171 | sets the | ||
172 | .Fa trust | ||
173 | identifier that can also be set using | ||
174 | .Xr X509_VERIFY_PARAM_set_trust 3 . | ||
175 | If the | ||
176 | .Fa trust | ||
177 | argument is 0 or invalid | ||
178 | or the trust identifier is already set to a non-zero value in the | ||
179 | .Vt X509_VERIFY_PARAM | ||
180 | object, no action occurs. | ||
181 | Here and in the following, | ||
182 | .Dv X509_TRUST_DEFAULT | ||
183 | counts as invalid. | ||
184 | .Pp | ||
185 | .Fn X509_STORE_CTX_set_purpose | ||
186 | sets the | ||
187 | .Fa purpose | ||
188 | identifier that can also be set using | ||
189 | .Xr X509_VERIFY_PARAM_set_purpose 3 . | ||
190 | If the | ||
191 | .Fa purpose | ||
192 | argument is 0 or any failure occurs, nothing is changed. | ||
193 | .Pp | ||
194 | In the following, the trust identifier contained in the | ||
195 | .Vt X509_PURPOSE | ||
196 | object associated with | ||
197 | .Fa purpose | ||
198 | is called the | ||
199 | .Dq associated trust . | ||
200 | .Pp | ||
201 | The function fails if the | ||
202 | .Fa purpose | ||
203 | argument or the associated trust is not 0 but invalid; otherwise, | ||
204 | .Fn X509_STORE_CTX_set_purpose | ||
205 | also does the equivalent of calling | ||
206 | .Fn X509_STORE_CTX_set_trust | ||
207 | with the associated trust. | ||
208 | .Pp | ||
209 | If the purpose identifier is already set to a non-zero value in the | ||
210 | .Vt X509_VERIFY_PARAM | ||
211 | object, it is not changed, even if the | ||
212 | .Fa purpose | ||
213 | argument is valid, too. | ||
214 | .Pp | ||
215 | .Fn X509_STORE_CTX_purpose_inherit | ||
216 | is similar to | ||
217 | .Fn X509_STORE_CTX_set_purpose , | ||
218 | with the following modifications: | ||
219 | .Bl -bullet | ||
220 | .It | ||
221 | If the | ||
222 | .Fa purpose | ||
223 | argument is 0, | ||
224 | .Fa def_purpose | ||
225 | is used instead. | ||
226 | .It | ||
227 | If the associated trust is | ||
228 | .Dv X509_TRUST_DEFAULT , | ||
229 | the trust associated with | ||
230 | .Fa def_purpose | ||
231 | is used instead, or if | ||
232 | .Fa def_purpose | ||
233 | is 0 or invalid, the function fails. | ||
234 | .It | ||
235 | If the | ||
236 | .Fa trust | ||
237 | argument is not 0, it is used instead of the associated trust, | ||
238 | and the equivalent of calling | ||
239 | .Fn X509_STORE_CTX_set_trust | ||
240 | is done even if both | ||
241 | .Fa purpose | ||
242 | and | ||
243 | .Fa def_purpose | ||
244 | are 0. | ||
245 | Even if the | ||
246 | .Fa trust | ||
247 | argument is not 0, if the (then unused) associated trust is | ||
248 | .Dv X509_TRUST_DEFAULT , | ||
249 | .Fa def_purpose | ||
250 | is still required to be valid. | ||
251 | .El | ||
252 | .Pp | ||
253 | Note that, even if all arguments are valid and the return value is 1, | ||
254 | it is possible that nothing changed, or that only either one of the | ||
255 | purpose and trust identifiers were set, or that both were set. | ||
256 | It can also happen that the purpose identifier gets set according to the | ||
257 | .Fa purpose | ||
258 | argument, but the trust identifier gets set according to the | ||
259 | .Fa def_purpose | ||
260 | argument in the same call. | ||
261 | .Pp | ||
262 | The intended way of using this function is to pass the purpose and | ||
263 | trust attributes of another structure of an arbitrary type as the | ||
264 | .Fa purpose | ||
265 | and | ||
266 | .Fa trust | ||
267 | arguments, and to provide | ||
268 | .Fa def_purpose | ||
269 | as 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 |
147 | retrieves an internal pointer to the verification parameters associated | 272 | retrieves an internal pointer to the verification parameters associated |
148 | with | 273 | with |
@@ -163,6 +288,61 @@ This uses the function | |||
163 | to find an appropriate set of parameters from | 288 | to 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 | ||
292 | returns 1 if the | ||
293 | .Fa trust | ||
294 | argument is 0 or valid or 0 if it is not 0 but invalid. | ||
295 | A return value of 1 does | ||
296 | .Em not | ||
297 | imply that the trust identifier stored in the | ||
298 | .Vt X509_VERIFY_PARAM | ||
299 | object was changed. | ||
300 | .Pp | ||
301 | .Fn X509_STORE_CTX_set_purpose | ||
302 | returns 1 if both the | ||
303 | .Fa purpose | ||
304 | argument and the associated trust are 0 or valid. | ||
305 | It returns 0 if either the | ||
306 | .Fa purpose | ||
307 | argument or the associated trust is not 0 but invalid. | ||
308 | A return value of 1 does not imply that any data was changed. | ||
309 | .Pp | ||
310 | .Fn X509_STORE_CTX_purpose_inherit | ||
311 | returns 0 if: | ||
312 | .Bl -bullet | ||
313 | .It | ||
314 | The | ||
315 | .Fa purpose | ||
316 | argument is not 0 and invalid. | ||
317 | .It | ||
318 | The | ||
319 | .Fa purpose | ||
320 | argument is 0 and the | ||
321 | .Fa def_purpose | ||
322 | argument is not 0 and invalid. | ||
323 | .It | ||
324 | The associated trust is | ||
325 | .Dv X509_TRUST_DEFAULT | ||
326 | and the | ||
327 | .Fa def_purpose | ||
328 | argument is 0 or invalid, | ||
329 | or the trust identifier associated with it is not 0 but invalid. | ||
330 | .It | ||
331 | The | ||
332 | .Fa trust | ||
333 | argument is not 0 and invalid. | ||
334 | .It | ||
335 | The | ||
336 | .Fa trust | ||
337 | argument is 0 and the associated trust is neither 0 nor | ||
338 | .Dv X509_TRUST_DEFAULT | ||
339 | but invalid. | ||
340 | .El | ||
341 | .Pp | ||
342 | Otherwise, | ||
343 | .Fn X509_STORE_CTX_purpose_inherit | ||
344 | returns 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 |
167 | returns a pointer to an | 347 | returns 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 |
174 | returns 1 for success or 0 if an error occurred. | 354 | returns 1 for success or 0 if an error occurred. |
355 | .Sh ERRORS | ||
356 | For | ||
357 | .Fn X509_STORE_CTX_set_trust , | ||
358 | .Fn X509_STORE_CTX_set_purpose , | ||
359 | and | ||
360 | .Fn X509_STORE_CTX_purpose_inherit , | ||
361 | the following diagnostics can be retrieved with | ||
362 | .Xr ERR_get_error 3 , | ||
363 | .Xr ERR_GET_REASON 3 , | ||
364 | and | ||
365 | .Xr ERR_reason_error_string 3 : | ||
366 | .Bl -tag -width Ds | ||
367 | .It Dv X509_R_UNKNOWN_TRUST_ID Qq "unknown trust id" | ||
368 | The | ||
369 | .Fa trust | ||
370 | argument or the trust identifier associated with | ||
371 | .Fa purpose | ||
372 | or | ||
373 | .Fa def_purpose | ||
374 | is not 0 but invalid, | ||
375 | .It Dv X509_R_UNKNOWN_PURPOSE_ID Qq "unknown purpose id" | ||
376 | The | ||
377 | .Fa purpose | ||
378 | argument is not 0 and invalid. | ||
379 | Or it is 0 and the | ||
380 | .Fa def_purpose | ||
381 | argument is not 0 and invalid. | ||
382 | Or the associated trust is | ||
383 | .Dv X509_TRUST_DEFAULT | ||
384 | and | ||
385 | .Fa def_purpose | ||
386 | is 0 or invalid. | ||
387 | .El | ||
388 | .Pp | ||
389 | The 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. | |||
184 | first appeared in OpenSSL 0.9.3 and has been available since | 399 | first 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 , | ||
404 | and | ||
405 | .Fn X509_STORE_CTX_purpose_inherit | ||
406 | first 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 |
188 | and | 410 | and |
189 | .Fn X509_STORE_CTX_set_time | 411 | .Fn X509_STORE_CTX_set_time |