summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/X509_LOOKUP_new.3
diff options
context:
space:
mode:
authorcvs2svn <admin@example.com>2021-08-18 16:06:57 +0000
committercvs2svn <admin@example.com>2021-08-18 16:06:57 +0000
commitd56c8fa8260d226f98b26f017b45b9c2b135f38d (patch)
tree348178b41617813cc93787187984a734ef8379ca /src/lib/libcrypto/man/X509_LOOKUP_new.3
parent18b9c1bcab7c37d8c5bd05b8e0d14d0c59d96650 (diff)
downloadopenbsd-tb_20210818.tar.gz
openbsd-tb_20210818.tar.bz2
openbsd-tb_20210818.zip
This commit was manufactured by cvs2git to create tag 'tb_20210818'.tb_20210818
Diffstat (limited to 'src/lib/libcrypto/man/X509_LOOKUP_new.3')
-rw-r--r--src/lib/libcrypto/man/X509_LOOKUP_new.3616
1 files changed, 0 insertions, 616 deletions
diff --git a/src/lib/libcrypto/man/X509_LOOKUP_new.3 b/src/lib/libcrypto/man/X509_LOOKUP_new.3
deleted file mode 100644
index 02420d664b..0000000000
--- a/src/lib/libcrypto/man/X509_LOOKUP_new.3
+++ /dev/null
@@ -1,616 +0,0 @@
1.\" $OpenBSD: X509_LOOKUP_new.3,v 1.4 2021/08/06 19:09:56 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: August 6 2021 $
18.Dt X509_LOOKUP_NEW 3
19.Os
20.Sh NAME
21.Nm X509_LOOKUP_new ,
22.Nm X509_LOOKUP_free ,
23.Nm X509_LOOKUP_ctrl ,
24.Nm X509_LOOKUP_add_dir ,
25.Nm X509_LOOKUP_load_file ,
26.Nm X509_LOOKUP_add_mem ,
27.Nm X509_LOOKUP_by_subject ,
28.Nm X509_LOOKUP_init ,
29.Nm X509_LOOKUP_shutdown ,
30.Nm X509_LOOKUP_by_issuer_serial ,
31.Nm X509_LOOKUP_by_fingerprint ,
32.Nm X509_LOOKUP_by_alias ,
33.Nm X509_get_default_cert_dir ,
34.Nm X509_get_default_cert_file ,
35.Nm X509_get_default_cert_dir_env ,
36.Nm X509_get_default_cert_file_env
37.\" X509_get_default_private_dir is intentionally undocumented
38.\" because it appears to be unused by any real-world software
39.\" and because it doesn't do much in the first place.
40.Nd certificate lookup object
41.Sh SYNOPSIS
42.In openssl/x509_vfy.h
43.Ft X509_LOOKUP *
44.Fn X509_LOOKUP_new "X509_LOOKUP_METHOD *method"
45.Ft void
46.Fn X509_LOOKUP_free "X509_LOOKUP *lookup"
47.Ft int
48.Fo X509_LOOKUP_ctrl
49.Fa "X509_LOOKUP *lookup"
50.Fa "int command"
51.Fa "const char *source"
52.Fa "long type"
53.Fa "char **ret"
54.Fc
55.Ft int
56.Fo X509_LOOKUP_add_dir
57.Fa "X509_LOOKUP *lookup"
58.Fa "const char *source"
59.Fa "long type"
60.Fc
61.Ft int
62.Fo X509_LOOKUP_load_file
63.Fa "X509_LOOKUP *lookup"
64.Fa "const char *source"
65.Fa "long type"
66.Fc
67.Ft int
68.Fo X509_LOOKUP_add_mem
69.Fa "X509_LOOKUP *lookup"
70.Fa "const struct iovec *source"
71.Fa "long type"
72.Fc
73.Ft int
74.Fo X509_LOOKUP_by_subject
75.Fa "X509_LOOKUP *lookup"
76.Fa "int type"
77.Fa "X509_NAME *name"
78.Fa "X509_OBJECT *object"
79.Fc
80.Ft int
81.Fn X509_LOOKUP_init "X509_LOOKUP *lookup"
82.Ft int
83.Fn X509_LOOKUP_shutdown "X509_LOOKUP *lookup"
84.Ft int
85.Fo X509_LOOKUP_by_issuer_serial
86.Fa "X509_LOOKUP *lookup"
87.Fa "int type"
88.Fa "X509_NAME *name"
89.Fa "ASN1_INTEGER *serial"
90.Fa "X509_OBJECT *object"
91.Fc
92.Ft int
93.Fo X509_LOOKUP_by_fingerprint
94.Fa "X509_LOOKUP *lookup"
95.Fa "int type"
96.Fa "const unsigned char *bytes"
97.Fa "int length"
98.Fa "X509_OBJECT *object"
99.Fc
100.Ft int
101.Fo X509_LOOKUP_by_alias
102.Fa "X509_LOOKUP *lookup"
103.Fa "int type"
104.Fa "const char *string"
105.Fa "int length"
106.Fa "X509_OBJECT *object"
107.Fc
108.In openssl/x509.h
109.Ft const char *
110.Fn X509_get_default_cert_dir void
111.Ft const char *
112.Fn X509_get_default_cert_file void
113.Ft const char *
114.Fn X509_get_default_cert_dir_env void
115.Ft const char *
116.Fn X509_get_default_cert_file_env void
117.Sh DESCRIPTION
118.Fn X509_LOOKUP_new
119allocates a new, empty
120.Vt X509_LOOKUP
121object and associates it with the
122.Fa method
123which is a static objects returned from either
124.Xr X509_LOOKUP_hash_dir 3
125or
126.Xr X509_LOOKUP_file 3
127or
128.Xr X509_LOOKUP_mem 3 .
129.Pp
130.Fn X509_LOOKUP_free
131releases the memory used by
132.Fa lookup .
133If
134.Fa lookup
135is a
136.Dv NULL
137pointer, no action occurs.
138.Pp
139The operation of
140.Fn X509_LOOKUP_ctrl
141depends on the
142.Vt X509_LOOKUP_METHOD
143used by
144.Fa lookup :
145.Bl -tag -width 4n
146.It Xr X509_LOOKUP_hash_dir 3
147The
148.Fa command
149is required to be
150.Dv X509_L_ADD_DIR
151and the
152.Fa source
153argument is interpreted
154as a colon-separated, NUL-terminated list of directory names.
155These directories are added to an internal list of directories to search
156for certificate files of the given
157.Fa type .
158.Pp
159If
160.Fa type
161is
162.Dv X509_FILETYPE_DEFAULT ,
163the
164.Fa source
165argument is ignored and
166.Pa /etc/ssl/certs
167and a type of
168.Dv X509_FILETYPE_PEM
169are used instead.
170.Pp
171.Fn X509_LOOKUP_add_dir
172is a macro that calls
173.Fn X509_LOOKUP_ctrl
174with a
175.Fa command
176of
177.Dv X509_L_ADD_DIR
178and
179.Fa ret
180set to
181.Dv NULL .
182.Pp
183This lookup method is peculiar in so far as calling
184.Fn X509_LOOKUP_ctrl
185on a lookup object using it does not yet add any certificates to the associated
186.Vt X509_STORE
187object.
188They need to be added selectively using
189.Fn X509_LOOKUP_by_subject .
190.It Xr X509_LOOKUP_file 3
191The
192.Fa command
193is required to be
194.Dv X509_L_FILE_LOAD
195and the
196.Fa source
197argument is interpreted as a NUL-terminated file name.
198If the
199.Fa type
200is
201.Dv X509_FILETYPE_PEM ,
202the file is read with
203.Xr BIO_new_file 3
204and
205.Xr PEM_X509_INFO_read_bio 3
206and the certificates and revocation lists found are added to the
207.Vt X509_STORE
208object associated with
209.Fa lookup
210using
211.Xr X509_STORE_add_cert 3
212and
213.Xr X509_STORE_add_crl 3 .
214If
215.Fa type
216is
217.Dv X509_FILETYPE_DEFAULT ,
218the
219.Fa source
220argument is ignored and
221.Pa /etc/ssl/certs.pem
222and a type of
223.Dv X509_FILETYPE_PEM
224are used instead.
225If
226.Fa type
227is
228.Dv X509_FILETYPE_ASN1 ,
229the file is read with
230.Xr d2i_X509_bio 3
231and the single certificate is added to the
232.Vt X509_STORE
233object associated with
234.Fa lookup
235using
236.Xr X509_STORE_add_cert 3 .
237.Pp
238.Fn X509_LOOKUP_load_file
239is a macro calling
240.Fn X509_LOOKUP_ctrl
241with a
242.Fa command
243of
244.Dv X509_L_FILE_LOAD
245and
246.Fa ret
247set to
248.Dv NULL .
249.It Xr X509_LOOKUP_mem 3
250The
251.Fa command
252and
253.Fa type
254are required to be
255.Dv X509_L_MEM
256and
257.Dv X509_FILETYPE_PEM ,
258respectively.
259The
260.Fa source
261argument is interpreted as a pointer to an
262.Vt iovec
263structure defined in
264.In sys/uio.h .
265The memory area described by that structure is read with
266.Xr BIO_new_mem_buf 3
267and
268.Xr PEM_X509_INFO_read_bio 3
269and the certificates and revocation lists found are added to the
270.Vt X509_STORE
271object associated with
272.Fa lookup
273using
274.Xr X509_STORE_add_cert 3
275and
276.Xr X509_STORE_add_crl 3 .
277.Pp
278.Fn X509_LOOKUP_add_mem
279is a macro calling
280.Fn X509_LOOKUP_ctrl
281with a command of
282.Dv X509_L_MEM
283and
284.Fa ret
285set to
286.Dv NULL .
287.El
288.Pp
289.Fn X509_LOOKUP_ctrl
290always ignores the
291.Fa ret
292argument when the built-in
293.Vt X509_LOOKUP_METHOD
294objects are used.
295.Pp
296When using built-in
297.Vt X509_LOOKUP_METHOD
298objects,
299.Fn X509_LOOKUP_by_subject
300is only useful if
301.Fa lookup
302uses
303.Xr X509_LOOKUP_hash_dir 3 .
304It passes the
305.Fa name
306to
307.Xr X509_NAME_hash 3
308and converts the resulting hash to an eight-digit lower-case
309hexadecimal number.
310.Pp
311If the
312.Fa type
313is
314.Dv X509_LU_X509 ,
315it searches the configured directories for files having that name,
316with a file name extension that is a small, non-negative decimal integer
317starting at
318.Qq ".0" .
319These files are read with
320.Xr X509_load_cert_file 3 .
321In each directory, the search is ended once a file with the expected name
322and extension does not exists.
323.Pp
324If the
325.Fa type
326is
327.Dv X509_LU_CRL ,
328the file name extensions are expected to have a prefix of
329.Qq "r" ,
330i.e. they start with
331.Qq ".r0" ,
332and the files are read with
333.Xr X509_load_crl_file 3 .
334.Pp
335In case of success, the first match is returned in the
336.Pf * Fa object
337provided by the caller, overwriting any previous content.
338.Pp
339Unless an application program manually constructs its own
340.Vt X509_LOOKUP_METHOD
341object containing its own callback functions,
342.Fn X509_LOOKUP_init ,
343.Fn X509_LOOKUP_shutdown ,
344.Fn X509_LOOKUP_by_issuer_serial ,
345.Fn X509_LOOKUP_by_fingerprint ,
346and
347.Fn X509_LOOKUP_by_alias
348have no effect.
349.Fn X509_LOOKUP_init
350is supposed to be called after
351.Fn X509_LOOKUP_new
352and before using the
353.Fa lookup
354object,
355.Fn X509_LOOKUP_shutdown
356after using it and before
357.Fn X509_LOOKUP_free .
358.Sh RETURN VALUES
359.Fn X509_LOOKUP_new
360returns the new object or
361.Dv NULL
362if memory allocation fails.
363.Pp
364.Fn X509_LOOKUP_ctrl
365returns 1 for success or 0 for failure.
366If
367.Fa lookup
368uses a user-defined
369.Vt X509_LOOKUP_METHOD
370object, it might also return \-1 for internal errors.
371.Pp
372.Fn X509_LOOKUP_by_subject
373returns
374.Dv X509_LU_X509
375for success or
376.Dv X509_LU_FAIL
377for failure.
378In particular, it fails if
379.Fa lookup
380uses
381.Xr X509_LOOKUP_file 3
382or
383.Xr X509_LOOKUP_mem 3 ,
384if
385.Fa name
386is
387.Dv NULL ,
388if
389.Fa type
390is neither
391.Dv X509_LU_X509
392nor
393.Dv X509_LU_CRL ,
394if no match is found, or if memory allocation fails.
395If
396.Fa lookup
397uses a user-defined
398.Vt X509_LOOKUP_METHOD
399object, it might also return negative values for internal errors.
400.Pp
401.Fn X509_LOOKUP_init
402and
403.Fn X509_LOOKUP_shutdown
404are supposed to return 1 for success and 0 for failure.
405When using the built-in
406.Vt X509_LOOKUP_METHOD
407objects, they always return 1.
408.Pp
409.Fn X509_LOOKUP_by_issuer_serial ,
410.Fn X509_LOOKUP_by_fingerprint ,
411and
412.Fn X509_LOOKUP_by_alias
413always return
414.Dv X509_LU_FAIL
415when using the built-in
416.Vt X509_LOOKUP_METHOD
417objects.
418.Pp
419.Fn X509_get_default_cert_dir
420returns a pointer to the constant string
421.Qq /etc/ssl/certs ,
422.Fn X509_get_default_cert_file
423to
424.Qq /etc/ssl/certs.pem ,
425.Fn X509_get_default_cert_dir_env
426to
427.Qq SSL_CERT_DIR ,
428and
429.Fn X509_get_default_cert_file_env
430to
431.Qq SSL_CERT_FILE .
432.Sh ENVIRONMENT
433For reasons of security and simplicity,
434LibreSSL ignores the environment variables
435.Ev SSL_CERT_DIR
436and
437.Ev SSL_CERT_FILE ,
438but other library implementations may use their contents instead
439of the standard locations for trusted certificates, and a few
440third-party application programs also inspect these variables
441directly and may pass their values to
442.Fn X509_LOOKUP_add_dir
443and
444.Fn X509_LOOKUP_load_file .
445.Sh FILES
446.Bl -tag -width /etc/ssl/certs.pem -compact
447.It Pa /etc/ssl/certs/
448default directory for storing trusted certificates
449.It Pa /etc/ssl/certs.pem
450default file for storing trusted certificates
451.El
452.Sh ERRORS
453The following diagnostics can be retrieved with
454.Xr ERR_get_error 3 ,
455.Xr ERR_GET_REASON 3 ,
456and
457.Xr ERR_reason_error_string 3 :
458.Bl -tag -width Ds
459.It Dv ERR_R_ASN1_LIB Qq "ASN1 lib"
460.Xr d2i_X509_bio 3
461failed in
462.Fn X509_LOOKUP_ctrl .
463.It Dv X509_R_BAD_X509_FILETYPE Qq "bad x509 filetype"
464.Fn X509_LOOKUP_ctrl
465was called with an invalid
466.Fa type .
467.It Dv ERR_R_BUF_LIB Qq "BUF lib"
468Memory allocation failed in
469.Fn X509_LOOKUP_by_subject .
470.It Dv X509_R_INVALID_DIRECTORY Qq "invalid directory"
471The
472.Fa source
473argument of
474.Fn X509_LOOKUP_ctrl
475with
476.Dv X509_L_ADD_DIR
477or
478.Fn X509_LOOKUP_add_dir
479was
480.Dv NULL
481or an empty string.
482.It Dv X509_R_LOADING_CERT_DIR Qq "loading cert dir"
483.Fn X509_LOOKUP_ctrl
484with
485.Dv X509_L_ADD_DIR
486or
487.Fn X509_LOOKUP_add_dir
488was called with
489.Dv X509_FILETYPE_DEFAULT
490and adding the default directories failed.
491This error is added after and in addition to a more specific diagnostic.
492.It Dv X509_R_LOADING_DEFAULTS Qq "loading defaults"
493.Fn X509_LOOKUP_ctrl
494with
495.Dv X509_L_FILE_LOAD
496or
497.Fn X509_LOOKUP_load_file
498was called with
499.Dv X509_FILETYPE_DEFAULT
500and adding the certificates and revocation lists failed.
501This error is added after and in addition to a more specific diagnostic.
502.It Dv ERR_R_MALLOC_FAILURE Qq "malloc failure"
503Memory allocation failed in
504.Fn X509_LOOKUP_ctrl
505or
506.Fn X509_LOOKUP_by_subject .
507.It Dv ERR_R_PEM_LIB Qq "PEM lib"
508.Xr PEM_X509_INFO_read_bio 3 ,
509.Xr PEM_read_bio_X509_AUX 3 ,
510or
511.Xr PEM_read_bio_X509_CRL 3
512failed in
513.Fn X509_LOOKUP_ctrl .
514.It Dv ERR_R_SYS_LIB Qq "system lib"
515.Xr BIO_new 3 ,
516.Xr BIO_new_file 3 ,
517or
518.Xr BIO_read_filename 3
519failed in
520.Fn X509_LOOKUP_ctrl .
521.It Dv X509_R_WRONG_LOOKUP_TYPE Qq "wrong lookup type"
522.Fn X509_LOOKUP_by_subject
523was called with an invalid
524.Fa type .
525.El
526.Pp
527Passing an invalid
528.Fa command
529to
530.Fn X509_LOOKUP_ctrl
531or calling
532.Fn X509_LOOKUP_by_subject
533with a
534.Dv NULL
535.Fa name
536or with arguments that yield no match
537causes failure but provides no diagnostics.
538.Sh SEE ALSO
539.Xr d2i_X509_bio 3 ,
540.Xr PEM_read_bio_X509_AUX 3 ,
541.Xr PEM_X509_INFO_read_bio 3 ,
542.Xr X509_LOOKUP_hash_dir 3 ,
543.Xr X509_NAME_hash 3 ,
544.Xr X509_NAME_new 3 ,
545.Xr X509_new 3 ,
546.Xr X509_OBJECT_get_type 3 ,
547.Xr X509_STORE_add_cert 3 ,
548.Xr X509_STORE_get_by_subject 3
549.Sh HISTORY
550.Fn X509_get_default_cert_dir ,
551.Fn X509_get_default_cert_file ,
552.Fn X509_get_default_cert_dir_env ,
553and
554.Fn X509_get_default_cert_file_env
555first appeared in SSLeay 0.4.1 and have been available since
556.Ox 2.4 .
557.Pp
558.Fn X509_LOOKUP_add_mem
559first appeared in
560.Ox 5.7 .
561.Pp
562The other functions first appeared in SSLeay 0.8.0
563and have been available since
564.Ox 2.4 .
565.Sh BUGS
566If the
567.Fa type
568is
569.Dv X509_FILETYPE_DEFAULT
570or
571.Dv X509_FILETYPE_PEM ,
572.Fn X509_LOOKUP_ctrl
573with
574.Dv X509_L_FILE_LOAD
575and
576.Fn X509_LOOKUP_load_file
577silently ignore failure of
578.Xr X509_STORE_add_cert 3
579and
580.Xr X509_STORE_add_crl 3
581and indicate success anyway.
582.Pp
583Handling of a
584.Dv NULL
585.Fa source
586is inconsistent for
587.Fn X509_LOOKUP_ctrl
588with
589.Dv X509_L_FILE_LOAD
590and for
591.Fn X509_LOOKUP_load_file .
592With
593.Dv X509_FILETYPE_PEM ,
594it causes failure, but with
595.Dv X509_FILETYPE_ASN1 ,
596no action occurs and success is indicated.
597.Pp
598When called on a
599.Fa lookup
600object using
601.Xr X509_LOOKUP_mem 3 ,
602.Fn X509_LOOKUP_ctrl
603raises
604.Dv ERR_R_PEM_LIB
605when called with an invalid
606.Fa command
607or
608.Fa type ,
609when
610.Xr BIO_new_mem_buf 3
611fails, when
612.Fa source
613contains zero objects, or when
614.Xr X509_STORE_add_cert 3
615fails on the first object encountered, which is all inconsistent
616with the behaviour of the other lookup methods.