1X509_LOOKUP_HASH_DIR(3ossl) OpenSSL X509_LOOKUP_HASH_DIR(3ossl)
2
3
4
6 X509_LOOKUP_hash_dir, X509_LOOKUP_file, X509_LOOKUP_store,
7 X509_load_cert_file_ex, X509_load_cert_file, X509_load_crl_file,
8 X509_load_cert_crl_file_ex, X509_load_cert_crl_file - Default OpenSSL
9 certificate lookup methods
10
12 #include <openssl/x509_vfy.h>
13
14 X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void);
15 X509_LOOKUP_METHOD *X509_LOOKUP_file(void);
16 X509_LOOKUP_METHOD *X509_LOOKUP_store(void);
17
18 int X509_load_cert_file_ex(X509_LOOKUP *ctx, const char *file, int type,
19 OSSL_LIB_CTX *libctx, const char *propq);
20 int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type);
21 int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type);
22 int X509_load_cert_crl_file_ex(X509_LOOKUP *ctx, const char *file, int type,
23 OSSL_LIB_CTX *libctx, const char *propq);
24 int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type);
25
27 X509_LOOKUP_hash_dir and X509_LOOKUP_file are two certificate lookup
28 methods to use with X509_STORE, provided by OpenSSL library.
29
30 Users of the library typically do not need to create instances of these
31 methods manually, they would be created automatically by
32 X509_STORE_load_locations(3) or SSL_CTX_load_verify_locations(3)
33 functions.
34
35 Internally loading of certificates and CRLs is implemented via
36 functions X509_load_cert_crl_file, X509_load_cert_file and
37 X509_load_crl_file. These functions support parameter type, which can
38 be one of constants FILETYPE_PEM, FILETYPE_ASN1 and FILETYPE_DEFAULT.
39 They load certificates and/or CRLs from specified file into memory
40 cache of X509_STORE objects which given ctx parameter is associated
41 with.
42
43 Functions X509_load_cert_file and X509_load_crl_file can load both PEM
44 and DER formats depending of type value. Because DER format cannot
45 contain more than one certificate or CRL object (while PEM can contain
46 several concatenated PEM objects) X509_load_cert_crl_file with
47 FILETYPE_ASN1 is equivalent to X509_load_cert_file.
48
49 Constant FILETYPE_DEFAULT with NULL filename causes these functions to
50 load default certificate store file (see
51 X509_STORE_set_default_paths(3).
52
53 Functions return number of objects loaded from file or 0 in case of
54 error.
55
56 Both methods support adding several certificate locations into one
57 X509_STORE.
58
59 This page documents certificate store formats used by these methods and
60 caching policy.
61
62 File Method
63 The X509_LOOKUP_file method loads all the certificates or CRLs present
64 in a file into memory at the time the file is added as a lookup source.
65
66 File format is ASCII text which contains concatenated PEM certificates
67 and CRLs.
68
69 This method should be used by applications which work with a small set
70 of CAs.
71
72 Hashed Directory Method
73 X509_LOOKUP_hash_dir is a more advanced method, which loads
74 certificates and CRLs on demand, and caches them in memory once they
75 are loaded. As of OpenSSL 1.0.0, it also checks for newer CRLs upon
76 each lookup, so that newer CRLs are as soon as they appear in the
77 directory.
78
79 The directory should contain one certificate or CRL per file in PEM
80 format, with a filename of the form hash.N for a certificate, or
81 hash.rN for a CRL. The hash is the value returned by the
82 X509_NAME_hash_ex(3) function applied to the subject name for
83 certificates or issuer name for CRLs. The hash can also be obtained
84 via the -hash option of the openssl-x509(1) or openssl-crl(1) commands.
85
86 The .N or .rN suffix is a sequence number that starts at zero, and is
87 incremented consecutively for each certificate or CRL with the same
88 hash value. Gaps in the sequence numbers are not supported, it is
89 assumed that there are no more objects with the same hash beyond the
90 first missing number in the sequence.
91
92 Sequence numbers make it possible for the directory to contain multiple
93 certificates with same subject name hash value. For example, it is
94 possible to have in the store several certificates with same subject or
95 several CRLs with same issuer (and, for example, different validity
96 period).
97
98 When checking for new CRLs once one CRL for given hash value is loaded,
99 hash_dir lookup method checks only for certificates with sequence
100 number greater than that of the already cached CRL.
101
102 Note that the hash algorithm used for subject name hashing changed in
103 OpenSSL 1.0.0, and all certificate stores have to be rehashed when
104 moving from OpenSSL 0.9.8 to 1.0.0.
105
106 OpenSSL includes a openssl-rehash(1) utility which creates symlinks
107 with hashed names for all files with .pem suffix in a given directory.
108
109 OSSL_STORE Method
110 X509_LOOKUP_store is a method that allows access to any store of
111 certificates and CRLs through any loader supported by ossl_store(7).
112 It works with the help of URIs, which can be direct references to
113 certificates or CRLs, but can also be references to catalogues of such
114 objects (that behave like directories).
115
116 This method overlaps the "File Method" and "Hashed Directory Method"
117 because of the 'file:' scheme loader. It does no caching of its own,
118 but can use a caching ossl_store(7) loader, and therefore depends on
119 the loader's capability.
120
122 X509_LOOKUP_hash_dir(), X509_LOOKUP_file() and X509_LOOKUP_store()
123 always return a valid X509_LOOKUP_METHOD structure.
124
125 X509_load_cert_file(), X509_load_crl_file() and
126 X509_load_cert_crl_file() return the number of loaded objects or 0 on
127 error.
128
130 PEM_read_PrivateKey(3), X509_STORE_load_locations(3),
131 SSL_CTX_load_verify_locations(3), X509_LOOKUP_meth_new(3),
132 ossl_store(7)
133
135 The functions X509_load_cert_file_ex(), X509_load_cert_crl_file_ex()
136 and X509_LOOKUP_store() were added in OpenSSL 3.0.
137
139 Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved.
140
141 Licensed under the Apache License 2.0 (the "License"). You may not use
142 this file except in compliance with the License. You can obtain a copy
143 in the file LICENSE in the source distribution or at
144 <https://www.openssl.org/source/license.html>.
145
146
147
1483.0.9 2023-07-27 X509_LOOKUP_HASH_DIR(3ossl)