2015-08-28 00:28:08 +08:00
|
|
|
=pod
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
2019-03-09 06:41:27 +08:00
|
|
|
X509_LOOKUP_hash_dir, X509_LOOKUP_file, X509_LOOKUP_store,
|
2020-09-24 17:42:23 +08:00
|
|
|
X509_load_cert_file_ex, X509_load_cert_file,
|
2015-08-28 00:28:08 +08:00
|
|
|
X509_load_crl_file,
|
2020-09-24 17:42:23 +08:00
|
|
|
X509_load_cert_crl_file_ex, X509_load_cert_crl_file
|
2020-07-24 20:53:27 +08:00
|
|
|
- Default OpenSSL certificate lookup methods
|
2015-08-28 00:28:08 +08:00
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
2017-01-21 02:58:49 +08:00
|
|
|
#include <openssl/x509_vfy.h>
|
2015-08-28 00:28:08 +08:00
|
|
|
|
2017-01-21 02:58:49 +08:00
|
|
|
X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void);
|
|
|
|
X509_LOOKUP_METHOD *X509_LOOKUP_file(void);
|
2019-03-09 06:41:27 +08:00
|
|
|
X509_LOOKUP_METHOD *X509_LOOKUP_store(void);
|
2015-08-28 00:28:08 +08:00
|
|
|
|
2020-09-24 17:42:23 +08:00
|
|
|
int X509_load_cert_file_ex(X509_LOOKUP *ctx, const char *file, int type,
|
2020-10-15 17:55:50 +08:00
|
|
|
OSSL_LIB_CTX *libctx, const char *propq);
|
2017-01-21 02:58:49 +08:00
|
|
|
int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type);
|
|
|
|
int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type);
|
2020-09-24 17:42:23 +08:00
|
|
|
int X509_load_cert_crl_file_ex(X509_LOOKUP *ctx, const char *file, int type,
|
2020-10-15 17:55:50 +08:00
|
|
|
OSSL_LIB_CTX *libctx, const char *propq);
|
2017-01-21 02:58:49 +08:00
|
|
|
int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type);
|
2015-08-28 00:28:08 +08:00
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
|
|
|
B<X509_LOOKUP_hash_dir> and B<X509_LOOKUP_file> are two certificate
|
|
|
|
lookup methods to use with B<X509_STORE>, provided by OpenSSL library.
|
|
|
|
|
2016-01-27 13:55:19 +08:00
|
|
|
Users of the library typically do not need to create instances of these
|
2015-08-28 00:28:08 +08:00
|
|
|
methods manually, they would be created automatically by
|
|
|
|
L<X509_STORE_load_locations(3)> or
|
|
|
|
L<SSL_CTX_load_verify_locations(3)>
|
|
|
|
functions.
|
|
|
|
|
|
|
|
Internally loading of certificates and CRLs is implemented via functions
|
|
|
|
B<X509_load_cert_crl_file>, B<X509_load_cert_file> and
|
|
|
|
B<X509_load_crl_file>. These functions support parameter I<type>, which
|
|
|
|
can be one of constants B<FILETYPE_PEM>, B<FILETYPE_ASN1> and
|
|
|
|
B<FILETYPE_DEFAULT>. They load certificates and/or CRLs from specified
|
|
|
|
file into memory cache of B<X509_STORE> objects which given B<ctx>
|
|
|
|
parameter is associated with.
|
|
|
|
|
|
|
|
Functions B<X509_load_cert_file> and
|
|
|
|
B<X509_load_crl_file> can load both PEM and DER formats depending of
|
|
|
|
type value. Because DER format cannot contain more than one certificate
|
|
|
|
or CRL object (while PEM can contain several concatenated PEM objects)
|
|
|
|
B<X509_load_cert_crl_file> with B<FILETYPE_ASN1> is equivalent to
|
|
|
|
B<X509_load_cert_file>.
|
|
|
|
|
|
|
|
Constant B<FILETYPE_DEFAULT> with NULL filename causes these functions
|
|
|
|
to load default certificate store file (see
|
2016-03-19 18:39:47 +08:00
|
|
|
L<X509_STORE_set_default_paths(3)>.
|
2015-08-28 00:28:08 +08:00
|
|
|
|
|
|
|
|
|
|
|
Functions return number of objects loaded from file or 0 in case of
|
2016-05-20 20:11:46 +08:00
|
|
|
error.
|
2015-08-28 00:28:08 +08:00
|
|
|
|
|
|
|
Both methods support adding several certificate locations into one
|
|
|
|
B<X509_STORE>.
|
|
|
|
|
|
|
|
This page documents certificate store formats used by these methods and
|
|
|
|
caching policy.
|
|
|
|
|
2016-05-21 08:52:46 +08:00
|
|
|
=head2 File Method
|
2015-08-28 00:28:08 +08:00
|
|
|
|
2016-01-27 13:55:19 +08:00
|
|
|
The B<X509_LOOKUP_file> method loads all the certificates or CRLs
|
|
|
|
present in a file into memory at the time the file is added as a
|
|
|
|
lookup source.
|
2015-08-28 00:28:08 +08:00
|
|
|
|
|
|
|
File format is ASCII text which contains concatenated PEM certificates
|
|
|
|
and CRLs.
|
|
|
|
|
2016-01-27 13:55:19 +08:00
|
|
|
This method should be used by applications which work with a small
|
|
|
|
set of CAs.
|
2015-08-28 00:28:08 +08:00
|
|
|
|
2016-05-21 08:52:46 +08:00
|
|
|
=head2 Hashed Directory Method
|
2015-08-28 00:28:08 +08:00
|
|
|
|
2016-01-27 13:55:19 +08:00
|
|
|
B<X509_LOOKUP_hash_dir> is a more advanced method, which loads
|
|
|
|
certificates and CRLs on demand, and caches them in memory once
|
|
|
|
they are loaded. As of OpenSSL 1.0.0, it also checks for newer CRLs
|
|
|
|
upon each lookup, so that newer CRLs are as soon as they appear in
|
|
|
|
the directory.
|
|
|
|
|
|
|
|
The directory should contain one certificate or CRL per file in PEM format,
|
2019-09-28 01:17:09 +08:00
|
|
|
with a filename of the form I<hash>.I<N> for a certificate, or
|
2016-01-27 13:55:19 +08:00
|
|
|
I<hash>.B<r>I<N> for a CRL.
|
2020-12-28 18:27:31 +08:00
|
|
|
The I<hash> is the value returned by the L<X509_NAME_hash_ex(3)> function
|
|
|
|
applied to the subject name for certificates or issuer name for CRLs.
|
2019-11-02 04:26:05 +08:00
|
|
|
The hash can also be obtained via the B<-hash> option of the
|
|
|
|
L<openssl-x509(1)> or L<openssl-crl(1)> commands.
|
2016-01-27 13:55:19 +08:00
|
|
|
|
|
|
|
The .I<N> or .B<r>I<N> suffix is a sequence number that starts at zero, and is
|
|
|
|
incremented consecutively for each certificate or CRL with the same I<hash>
|
|
|
|
value.
|
|
|
|
Gaps in the sequence numbers are not supported, it is assumed that there are no
|
|
|
|
more objects with the same hash beyond the first missing number in the
|
|
|
|
sequence.
|
|
|
|
|
|
|
|
Sequence numbers make it possible for the directory to contain multiple
|
|
|
|
certificates with same subject name hash value.
|
|
|
|
For example, it is possible to have in the store several certificates with same
|
|
|
|
subject or several CRLs with same issuer (and, for example, different validity
|
|
|
|
period).
|
|
|
|
|
|
|
|
When checking for new CRLs once one CRL for given hash value is
|
|
|
|
loaded, hash_dir lookup method checks only for certificates with
|
|
|
|
sequence number greater than that of the already cached CRL.
|
|
|
|
|
|
|
|
Note that the hash algorithm used for subject name hashing changed in OpenSSL
|
|
|
|
1.0.0, and all certificate stores have to be rehashed when moving from OpenSSL
|
2015-08-28 00:28:08 +08:00
|
|
|
0.9.8 to 1.0.0.
|
|
|
|
|
2019-11-02 04:26:05 +08:00
|
|
|
OpenSSL includes a L<openssl-rehash(1)> utility which creates symlinks with
|
|
|
|
hashed names for all files with F<.pem> suffix in a given directory.
|
2015-08-28 00:28:08 +08:00
|
|
|
|
2019-03-09 06:41:27 +08:00
|
|
|
=head2 OSSL_STORE Method
|
|
|
|
|
|
|
|
B<X509_LOOKUP_store> is a method that allows access to any store of
|
|
|
|
certificates and CRLs through any loader supported by
|
2019-10-25 04:40:11 +08:00
|
|
|
L<ossl_store(7)>.
|
2019-03-09 06:41:27 +08:00
|
|
|
It works with the help of URIs, which can be direct references to
|
|
|
|
certificates or CRLs, but can also be references to catalogues of such
|
|
|
|
objects (that behave like directories).
|
|
|
|
|
|
|
|
This method overlaps the L</File Method> and L</Hashed Directory Method>
|
|
|
|
because of the 'file:' scheme loader.
|
2019-10-25 04:40:11 +08:00
|
|
|
It does no caching of its own, but can use a caching L<ossl_store(7)>
|
2019-03-09 06:41:27 +08:00
|
|
|
loader, and therefore depends on the loader's capability.
|
|
|
|
|
2017-12-25 17:50:39 +08:00
|
|
|
=head1 RETURN VALUES
|
|
|
|
|
2019-03-09 06:41:27 +08:00
|
|
|
X509_LOOKUP_hash_dir(), X509_LOOKUP_file() and X509_LOOKUP_store()
|
|
|
|
always return a valid B<X509_LOOKUP_METHOD> structure.
|
2017-12-25 17:50:39 +08:00
|
|
|
|
|
|
|
X509_load_cert_file(), X509_load_crl_file() and X509_load_cert_crl_file() return
|
|
|
|
the number of loaded objects or 0 on error.
|
|
|
|
|
2015-08-28 00:28:08 +08:00
|
|
|
=head1 SEE ALSO
|
|
|
|
|
2016-06-10 05:02:59 +08:00
|
|
|
L<PEM_read_PrivateKey(3)>,
|
2015-08-28 00:28:08 +08:00
|
|
|
L<X509_STORE_load_locations(3)>,
|
|
|
|
L<SSL_CTX_load_verify_locations(3)>,
|
2018-02-10 02:23:18 +08:00
|
|
|
L<X509_LOOKUP_meth_new(3)>,
|
2019-10-25 04:40:11 +08:00
|
|
|
L<ossl_store(7)>
|
2019-03-09 06:41:27 +08:00
|
|
|
|
|
|
|
=head1 HISTORY
|
|
|
|
|
2020-09-24 17:42:23 +08:00
|
|
|
The functions X509_load_cert_file_ex(),
|
|
|
|
X509_load_cert_crl_file_ex() and X509_LOOKUP_store() were added in
|
2020-07-24 20:53:27 +08:00
|
|
|
OpenSSL 3.0.
|
2015-08-28 00:28:08 +08:00
|
|
|
|
2016-05-18 23:44:05 +08:00
|
|
|
=head1 COPYRIGHT
|
|
|
|
|
2021-01-28 20:54:57 +08:00
|
|
|
Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved.
|
2016-05-18 23:44:05 +08:00
|
|
|
|
2018-12-06 21:04:44 +08:00
|
|
|
Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-05-18 23:44:05 +08:00
|
|
|
this file except in compliance with the License. You can obtain a copy
|
|
|
|
in the file LICENSE in the source distribution or at
|
|
|
|
L<https://www.openssl.org/source/license.html>.
|
|
|
|
|
|
|
|
=cut
|