1X509_LOOKUP_HASH_DIR(3)             OpenSSL            X509_LOOKUP_HASH_DIR(3)
2
3
4

NAME

6       X509_LOOKUP_hash_dir, X509_LOOKUP_file, X509_load_cert_file,
7       X509_load_crl_file, X509_load_cert_crl_file - Default OpenSSL
8       certificate lookup methods
9

SYNOPSIS

11        #include <openssl/x509_vfy.h>
12
13        X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void);
14        X509_LOOKUP_METHOD *X509_LOOKUP_file(void);
15
16        int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type);
17        int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type);
18        int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type);
19

DESCRIPTION

21       X509_LOOKUP_hash_dir and X509_LOOKUP_file are two certificate lookup
22       methods to use with X509_STORE, provided by OpenSSL library.
23
24       Users of the library typically do not need to create instances of these
25       methods manually, they would be created automatically by
26       X509_STORE_load_locations(3) or SSL_CTX_load_verify_locations(3)
27       functions.
28
29       Internally loading of certificates and CRLs is implemented via
30       functions X509_load_cert_crl_file, X509_load_cert_file and
31       X509_load_crl_file. These functions support parameter type, which can
32       be one of constants FILETYPE_PEM, FILETYPE_ASN1 and FILETYPE_DEFAULT.
33       They load certificates and/or CRLs from specified file into memory
34       cache of X509_STORE objects which given ctx parameter is associated
35       with.
36
37       Functions X509_load_cert_file and X509_load_crl_file can load both PEM
38       and DER formats depending of type value. Because DER format cannot
39       contain more than one certificate or CRL object (while PEM can contain
40       several concatenated PEM objects) X509_load_cert_crl_file with
41       FILETYPE_ASN1 is equivalent to X509_load_cert_file.
42
43       Constant FILETYPE_DEFAULT with NULL filename causes these functions to
44       load default certificate store file (see
45       X509_STORE_set_default_paths(3).
46
47       Functions return number of objects loaded from file or 0 in case of
48       error.
49
50       Both methods support adding several certificate locations into one
51       X509_STORE.
52
53       This page documents certificate store formats used by these methods and
54       caching policy.
55
56   File Method
57       The X509_LOOKUP_file method loads all the certificates or CRLs present
58       in a file into memory at the time the file is added as a lookup source.
59
60       File format is ASCII text which contains concatenated PEM certificates
61       and CRLs.
62
63       This method should be used by applications which work with a small set
64       of CAs.
65
66   Hashed Directory Method
67       X509_LOOKUP_hash_dir is a more advanced method, which loads
68       certificates and CRLs on demand, and caches them in memory once they
69       are loaded. As of OpenSSL 1.0.0, it also checks for newer CRLs upon
70       each lookup, so that newer CRLs are as soon as they appear in the
71       directory.
72
73       The directory should contain one certificate or CRL per file in PEM
74       format, with a filename of the form hash.N for a certificate, or
75       hash.rN for a CRL.  The hash is the value returned by the
76       X509_NAME_hash(3) function applied to the subject name for certificates
77       or issuer name for CRLs.  The hash can also be obtained via the -hash
78       option of the x509(1) or crl(1) commands.
79
80       The .N or .rN suffix is a sequence number that starts at zero, and is
81       incremented consecutively for each certificate or CRL with the same
82       hash value.  Gaps in the sequence numbers are not supported, it is
83       assumed that there are no more objects with the same hash beyond the
84       first missing number in the sequence.
85
86       Sequence numbers make it possible for the directory to contain multiple
87       certificates with same subject name hash value.  For example, it is
88       possible to have in the store several certificates with same subject or
89       several CRLs with same issuer (and, for example, different validity
90       period).
91
92       When checking for new CRLs once one CRL for given hash value is loaded,
93       hash_dir lookup method checks only for certificates with sequence
94       number greater than that of the already cached CRL.
95
96       Note that the hash algorithm used for subject name hashing changed in
97       OpenSSL 1.0.0, and all certificate stores have to be rehashed when
98       moving from OpenSSL 0.9.8 to 1.0.0.
99
100       OpenSSL includes a rehash(1) utility which creates symlinks with
101       correct hashed names for all files with .pem suffix in a given
102       directory.
103

RETURN VALUES

105       X509_LOOKUP_hash_dir() and X509_LOOKUP_file() always return a valid
106       X509_LOOKUP_METHOD structure.
107
108       X509_load_cert_file(), X509_load_crl_file() and
109       X509_load_cert_crl_file() return the number of loaded objects or 0 on
110       error.
111

SEE ALSO

113       PEM_read_PrivateKey(3), X509_STORE_load_locations(3),
114       X509_store_add_lookup(3), SSL_CTX_load_verify_locations(3),
115       X509_LOOKUP_meth_new(3),
116
118       Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
119
120       Licensed under the OpenSSL license (the "License").  You may not use
121       this file except in compliance with the License.  You can obtain a copy
122       in the file LICENSE in the source distribution or at
123       <https://www.openssl.org/source/license.html>.
124
125
126
1271.1.1i                            2021-01-26           X509_LOOKUP_HASH_DIR(3)
Impressum