2 * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
11 #include "internal/cryptlib.h"
12 #include <openssl/crypto.h>
13 #include <openssl/x509.h>
15 int X509_STORE_set_default_paths_with_libctx(X509_STORE *ctx,
21 lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_file());
24 X509_LOOKUP_load_file_with_libctx(lookup, NULL, X509_FILETYPE_DEFAULT,
27 lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_hash_dir());
30 X509_LOOKUP_add_dir(lookup, NULL, X509_FILETYPE_DEFAULT);
32 lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_store());
35 X509_LOOKUP_add_store_with_libctx(lookup, NULL, libctx, propq);
37 /* clear any errors */
42 int X509_STORE_set_default_paths(X509_STORE *ctx)
44 return X509_STORE_set_default_paths_with_libctx(ctx, NULL, NULL);
47 int X509_STORE_load_file_with_libctx(X509_STORE *ctx, const char *file,
48 OPENSSL_CTX *libctx, const char *propq)
53 || (lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_file())) == NULL
54 || X509_LOOKUP_load_file_with_libctx(lookup, file, X509_FILETYPE_PEM,
61 int X509_STORE_load_file(X509_STORE *ctx, const char *file)
63 return X509_STORE_load_file_with_libctx(ctx, file, NULL, NULL);
66 int X509_STORE_load_path(X509_STORE *ctx, const char *path)
71 || (lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_hash_dir())) == NULL
72 || X509_LOOKUP_add_dir(lookup, path, X509_FILETYPE_PEM) == 0)
78 int X509_STORE_load_store_with_libctx(X509_STORE *ctx, const char *uri,
79 OPENSSL_CTX *libctx, const char *propq)
84 || (lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_store())) == NULL
85 || X509_LOOKUP_add_store_with_libctx(lookup, uri, libctx, propq) == 0)
91 int X509_STORE_load_store(X509_STORE *ctx, const char *uri)
93 return X509_STORE_load_store_with_libctx(ctx, uri, NULL, NULL);
96 int X509_STORE_load_locations_with_libctx(X509_STORE *ctx, const char *file,
98 OPENSSL_CTX *libctx, const char *propq)
100 if (file == NULL && path == NULL)
102 if (file != NULL && !X509_STORE_load_file_with_libctx(ctx, file,
105 if (path != NULL && !X509_STORE_load_path(ctx, path))
110 int X509_STORE_load_locations(X509_STORE *ctx, const char *file,
113 return X509_STORE_load_locations_with_libctx(ctx, file, path, NULL, NULL);