2017-07-18 01:44:03 +08:00
|
|
|
=pod
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
2020-01-31 22:35:46 +08:00
|
|
|
X509_STORE,
|
2017-07-18 01:44:03 +08:00
|
|
|
X509_STORE_add_cert, X509_STORE_add_crl, X509_STORE_set_depth,
|
|
|
|
X509_STORE_set_flags, X509_STORE_set_purpose, X509_STORE_set_trust,
|
2020-01-31 22:35:46 +08:00
|
|
|
X509_STORE_add_lookup,
|
2020-09-24 17:42:23 +08:00
|
|
|
X509_STORE_load_file_ex, X509_STORE_load_file, X509_STORE_load_path,
|
|
|
|
X509_STORE_load_store_ex, X509_STORE_load_store,
|
|
|
|
X509_STORE_set_default_paths_ex, X509_STORE_set_default_paths,
|
|
|
|
X509_STORE_load_locations_ex, X509_STORE_load_locations
|
2017-07-18 01:44:03 +08:00
|
|
|
- X509_STORE manipulation
|
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
|
|
|
#include <openssl/x509_vfy.h>
|
|
|
|
|
2020-01-31 22:35:46 +08:00
|
|
|
typedef x509_store_st X509_STORE;
|
|
|
|
|
2022-07-20 21:33:51 +08:00
|
|
|
int X509_STORE_add_cert(X509_STORE *xs, X509 *x);
|
|
|
|
int X509_STORE_add_crl(X509_STORE *xs, X509_CRL *x);
|
2017-07-18 01:44:03 +08:00
|
|
|
int X509_STORE_set_depth(X509_STORE *store, int depth);
|
2022-07-20 21:33:51 +08:00
|
|
|
int X509_STORE_set_flags(X509_STORE *xs, unsigned long flags);
|
|
|
|
int X509_STORE_set_purpose(X509_STORE *xs, int purpose);
|
|
|
|
int X509_STORE_set_trust(X509_STORE *xs, int trust);
|
2017-07-18 01:44:03 +08:00
|
|
|
|
2020-01-31 22:35:46 +08:00
|
|
|
X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *store,
|
|
|
|
X509_LOOKUP_METHOD *meth);
|
|
|
|
|
2022-07-20 21:33:51 +08:00
|
|
|
int X509_STORE_set_default_paths_ex(X509_STORE *xs, OSSL_LIB_CTX *libctx,
|
2020-09-24 17:42:23 +08:00
|
|
|
const char *propq);
|
2022-07-20 21:33:51 +08:00
|
|
|
int X509_STORE_set_default_paths(X509_STORE *xs);
|
|
|
|
int X509_STORE_load_file_ex(X509_STORE *xs, const char *file,
|
2020-10-15 17:55:50 +08:00
|
|
|
OSSL_LIB_CTX *libctx, const char *propq);
|
2022-07-20 21:33:51 +08:00
|
|
|
int X509_STORE_load_file(X509_STORE *xs, const char *file);
|
|
|
|
int X509_STORE_load_path(X509_STORE *xs, const char *dir);
|
|
|
|
int X509_STORE_load_store_ex(X509_STORE *xs, const char *uri,
|
2020-10-15 17:55:50 +08:00
|
|
|
OSSL_LIB_CTX *libctx, const char *propq);
|
2022-07-20 21:33:51 +08:00
|
|
|
int X509_STORE_load_store(X509_STORE *xs, const char *uri);
|
|
|
|
int X509_STORE_load_locations_ex(X509_STORE *xs, const char *file,
|
2020-10-15 17:55:50 +08:00
|
|
|
const char *dir, OSSL_LIB_CTX *libctx,
|
2020-09-24 17:42:23 +08:00
|
|
|
const char *propq);
|
2022-07-20 21:33:51 +08:00
|
|
|
int X509_STORE_load_locations(X509_STORE *xs,
|
2017-07-18 01:44:03 +08:00
|
|
|
const char *file, const char *dir);
|
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
|
|
|
The B<X509_STORE> structure is intended to be a consolidated mechanism for
|
|
|
|
holding information about X.509 certificates and CRLs, and constructing
|
|
|
|
and validating chains of certificates terminating in trusted roots.
|
|
|
|
It admits multiple lookup mechanisms and efficient scaling performance
|
|
|
|
with large numbers of certificates, and a great deal of flexibility in
|
|
|
|
how validation and policy checks are performed.
|
|
|
|
|
2020-12-24 06:29:04 +08:00
|
|
|
Details of the chain building and checking process are described in
|
|
|
|
L<openssl-verification-options(1)/Certification Path Building> and
|
|
|
|
L<openssl-verification-options(1)/Certification Path Validation>.
|
|
|
|
|
2017-07-18 01:44:03 +08:00
|
|
|
L<X509_STORE_new(3)> creates an empty B<X509_STORE> structure, which contains
|
|
|
|
no information about trusted certificates or where such certificates
|
|
|
|
are located on disk, and is generally not usable. Normally, trusted
|
|
|
|
certificates will be added to the B<X509_STORE> to prepare it for use,
|
|
|
|
via mechanisms such as X509_STORE_add_lookup() and X509_LOOKUP_file(), or
|
|
|
|
PEM_read_bio_X509_AUX() and X509_STORE_add_cert(). CRLs can also be added,
|
|
|
|
and many behaviors configured as desired.
|
|
|
|
|
|
|
|
Once the B<X509_STORE> is suitably configured, X509_STORE_CTX_new() is
|
|
|
|
used to instantiate a single-use B<X509_STORE_CTX> for each chain-building
|
|
|
|
and verification operation. That process includes providing the end-entity
|
|
|
|
certificate to be verified and an additional set of untrusted certificates
|
|
|
|
that may be used in chain-building. As such, it is expected that the
|
|
|
|
certificates included in the B<X509_STORE> are certificates that represent
|
|
|
|
trusted entities such as root certificate authorities (CAs).
|
|
|
|
OpenSSL represents these trusted certificates internally as B<X509> objects
|
|
|
|
with an associated B<X509_CERT_AUX>, as are produced by
|
|
|
|
PEM_read_bio_X509_AUX() and similar routines that refer to X509_AUX.
|
|
|
|
The public interfaces that operate on such trusted certificates still
|
|
|
|
operate on pointers to B<X509> objects, though.
|
|
|
|
|
|
|
|
X509_STORE_add_cert() and X509_STORE_add_crl() add the respective object
|
|
|
|
to the B<X509_STORE>'s local storage. Untrusted objects should not be
|
2019-08-14 10:28:07 +08:00
|
|
|
added in this way. The added object's reference count is incremented by one,
|
|
|
|
hence the caller retains ownership of the object and needs to free it when it
|
|
|
|
is no longer needed.
|
2017-07-18 01:44:03 +08:00
|
|
|
|
|
|
|
X509_STORE_set_depth(), X509_STORE_set_flags(), X509_STORE_set_purpose(),
|
|
|
|
X509_STORE_set_trust(), and X509_STORE_set1_param() set the default values
|
|
|
|
for the corresponding values used in certificate chain validation. Their
|
|
|
|
behavior is documented in the corresponding B<X509_VERIFY_PARAM> manual
|
|
|
|
pages, e.g., L<X509_VERIFY_PARAM_set_depth(3)>.
|
|
|
|
|
2020-01-31 22:35:46 +08:00
|
|
|
X509_STORE_add_lookup() finds or creates a L<X509_LOOKUP(3)> with the
|
|
|
|
L<X509_LOOKUP_METHOD(3)> I<meth> and adds it to the B<X509_STORE>
|
|
|
|
I<store>. This also associates the B<X509_STORE> with the lookup, so
|
|
|
|
B<X509_LOOKUP> functions can look up objects in that store.
|
|
|
|
|
2020-09-24 17:42:23 +08:00
|
|
|
X509_STORE_load_file_ex() loads trusted certificate(s) into an
|
2020-07-24 20:53:27 +08:00
|
|
|
B<X509_STORE> from a given file. The library context I<libctx> and property
|
2021-03-24 16:11:13 +08:00
|
|
|
query I<propq> are used when fetching algorithms from providers.
|
2020-07-24 20:53:27 +08:00
|
|
|
|
2020-09-24 17:42:23 +08:00
|
|
|
X509_STORE_load_file() is similar to X509_STORE_load_file_ex() but
|
2021-03-24 16:11:13 +08:00
|
|
|
uses NULL for the library context I<libctx> and property query I<propq>.
|
2019-03-09 06:41:27 +08:00
|
|
|
|
|
|
|
X509_STORE_load_path() loads trusted certificate(s) into an
|
|
|
|
B<X509_STORE> from a given directory path.
|
|
|
|
The certificates in the directory must be in hashed form, as
|
|
|
|
documented in L<X509_LOOKUP_hash_dir(3)>.
|
|
|
|
|
2020-09-24 17:42:23 +08:00
|
|
|
X509_STORE_load_store_ex() loads trusted certificate(s) into an
|
2020-07-24 20:53:27 +08:00
|
|
|
B<X509_STORE> from a store at a given URI. The library context I<libctx> and
|
2021-03-24 16:11:13 +08:00
|
|
|
property query I<propq> are used when fetching algorithms from providers.
|
2019-03-09 06:41:27 +08:00
|
|
|
|
2020-09-24 17:42:23 +08:00
|
|
|
X509_STORE_load_store() is similar to X509_STORE_load_store_ex() but
|
2021-03-24 16:11:13 +08:00
|
|
|
uses NULL for the library context I<libctx> and property query I<propq>.
|
2020-07-24 20:53:27 +08:00
|
|
|
|
2020-09-24 17:42:23 +08:00
|
|
|
X509_STORE_load_locations_ex() combines
|
2022-09-13 15:03:21 +08:00
|
|
|
X509_STORE_load_file_ex() and X509_STORE_load_path() for a given file
|
2020-07-24 20:53:27 +08:00
|
|
|
and/or directory path.
|
2019-03-09 06:41:27 +08:00
|
|
|
It is permitted to specify just a file, just a directory, or both
|
|
|
|
paths.
|
2017-07-18 01:44:03 +08:00
|
|
|
|
2020-09-24 17:42:23 +08:00
|
|
|
X509_STORE_load_locations() is similar to X509_STORE_load_locations_ex()
|
2021-03-24 16:11:13 +08:00
|
|
|
but uses NULL for the library context I<libctx> and property query I<propq>.
|
2020-07-24 20:53:27 +08:00
|
|
|
|
2020-09-24 17:42:23 +08:00
|
|
|
X509_STORE_set_default_paths_ex() is somewhat misnamed, in that it does
|
2020-07-24 20:53:27 +08:00
|
|
|
not set what default paths should be used for loading certificates. Instead,
|
2017-07-18 01:44:03 +08:00
|
|
|
it loads certificates into the B<X509_STORE> from the hardcoded default
|
2021-03-24 16:11:13 +08:00
|
|
|
paths. The library context I<libctx> and property query I<propq> are used when
|
2020-07-24 20:53:27 +08:00
|
|
|
fetching algorithms from providers.
|
|
|
|
|
|
|
|
X509_STORE_set_default_paths() is similar to
|
2020-09-24 17:42:23 +08:00
|
|
|
X509_STORE_set_default_paths_ex() but uses NULL for the library
|
2021-03-24 16:11:13 +08:00
|
|
|
context I<libctx> and property query I<propq>.
|
2017-07-18 01:44:03 +08:00
|
|
|
|
|
|
|
=head1 RETURN VALUES
|
|
|
|
|
|
|
|
X509_STORE_add_cert(), X509_STORE_add_crl(), X509_STORE_set_depth(),
|
2020-07-24 20:53:27 +08:00
|
|
|
X509_STORE_set_flags(), X509_STORE_set_purpose(), X509_STORE_set_trust(),
|
2020-09-24 17:42:23 +08:00
|
|
|
X509_STORE_load_file_ex(), X509_STORE_load_file(),
|
2020-07-24 20:53:27 +08:00
|
|
|
X509_STORE_load_path(),
|
2020-09-24 17:42:23 +08:00
|
|
|
X509_STORE_load_store_ex(), X509_STORE_load_store(),
|
|
|
|
X509_STORE_load_locations_ex(), X509_STORE_load_locations(),
|
|
|
|
X509_STORE_set_default_paths_ex() and X509_STORE_set_default_paths()
|
2020-07-24 20:53:27 +08:00
|
|
|
return 1 on success or 0 on failure.
|
2017-07-18 01:44:03 +08:00
|
|
|
|
2020-01-31 22:35:46 +08:00
|
|
|
X509_STORE_add_lookup() returns the found or created
|
|
|
|
L<X509_LOOKUP(3)>, or NULL on error.
|
|
|
|
|
2017-07-18 01:44:03 +08:00
|
|
|
=head1 SEE ALSO
|
|
|
|
|
|
|
|
L<X509_LOOKUP_hash_dir(3)>.
|
|
|
|
L<X509_VERIFY_PARAM_set_depth(3)>.
|
|
|
|
L<X509_STORE_new(3)>,
|
|
|
|
L<X509_STORE_get0_param(3)>
|
|
|
|
|
2020-07-24 20:53:27 +08:00
|
|
|
=head1 HISTORY
|
|
|
|
|
2020-09-24 17:42:23 +08:00
|
|
|
The functions X509_STORE_set_default_paths_ex(),
|
2020-09-24 17:56:03 +08:00
|
|
|
X509_STORE_load_file_ex(), X509_STORE_load_store_ex() and
|
2020-09-24 17:42:23 +08:00
|
|
|
X509_STORE_load_locations_ex() were added in OpenSSL 3.0.
|
2020-07-24 20:53:27 +08:00
|
|
|
|
2017-07-18 01:44:03 +08:00
|
|
|
=head1 COPYRIGHT
|
|
|
|
|
2021-05-20 21:22:33 +08:00
|
|
|
Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved.
|
2017-07-18 01:44:03 +08:00
|
|
|
|
2018-12-06 21:04:44 +08:00
|
|
|
Licensed under the Apache License 2.0 (the "License"). You may not use
|
2017-07-18 01:44:03 +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
|