X509_LOOKUP_hash_dir

- NAME
- SYNOPSIS
- DESCRIPTION
  - File Method
  - Hashed Directory Method
- SEE ALSO
- COPYRIGHT

# NAME

X509_LOOKUP_hash_dir, X509_LOOKUP_file, X509_load_cert_file, X509_load_crl_file, X509_load_cert_crl_file - Default OpenSSL certificate lookup methods

# SYNOPSIS

      #include <openssl/x509_vfy.h>

      X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void);
      X509_LOOKUP_METHOD *X509_LOOKUP_file(void);

      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);
      int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type);

# DESCRIPTION

X509_LOOKUP_hash_dir and X509_LOOKUP_file are two certificate lookup methods to use with X509_STORE, provided by OpenSSL library.

Users of the library typically do not need to create instances of these methods manually, they would be created automatically by SSL_CTX_load_verify_locations(3) functions.

Internally loading of certificates and CRLs is implemented via functions X509_load_cert_crl_file, X509_load_cert_file and X509_load_crl_file. These functions support parameter type, which can be one of constants FILETYPE_PEM, FILETYPE_ASN1 and FILETYPE_DEFAULT. They load certificates and/or CRLs from specified file into memory cache of X509_STORE objects which given ctx parameter is associated with.

Functions X509_load_cert_file and 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) X509_load_cert_crl_file with FILETYPE_ASN1 is equivalent to X509_load_cert_file.

Constant FILETYPE_DEFAULT with NULL filename causes these functions to load default certificate store file (see File Method

The 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.

File format is ASCII text which contains concatenated PEM certificates and CRLs.

This method should be used by applications which work with a small set of CAs.

## Hashed Directory Method

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, with a file name of the form hash.N for a certificate, or hash.rN for a CRL. The hash is the value returned by the x509(1) or c_rehash(1) utility which creates symlinks with correct hashed names for all files with .pem suffix in a given directory.

# SEE ALSO

d2i_X509_bio(3), X609_store_add_lookup(3), COPYRIGHT

Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the OpenSSL license (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at https://www.openssl.org/source/license.html.