2 * Copyright 1995-2016 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(X509_STORE *ctx)
19 lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_file());
22 X509_LOOKUP_load_file(lookup, NULL, X509_FILETYPE_DEFAULT);
24 lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_hash_dir());
27 X509_LOOKUP_add_dir(lookup, NULL, X509_FILETYPE_DEFAULT);
29 lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_store());
32 X509_LOOKUP_add_store(lookup, NULL);
34 /* clear any errors */
40 int X509_STORE_load_file(X509_STORE *ctx, const char *file)
45 || (lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_file())) == NULL
46 || X509_LOOKUP_load_file(lookup, file, X509_FILETYPE_PEM) == 0)
52 int X509_STORE_load_path(X509_STORE *ctx, const char *path)
57 || (lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_hash_dir())) == NULL
58 || X509_LOOKUP_add_dir(lookup, path, X509_FILETYPE_PEM) == 0)
64 int X509_STORE_load_store(X509_STORE *ctx, const char *uri)
69 || (lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_store())) == NULL
70 || X509_LOOKUP_add_store(lookup, uri) == 0)
77 #ifndef OPENSSL_NO_DEPRECATED_3_0
78 int X509_STORE_load_locations(X509_STORE *ctx, const char *file,
81 if (file == NULL && path == NULL)
83 if (file != NULL && !X509_STORE_load_file(ctx, file))
85 if (path != NULL && !X509_STORE_load_path(ctx, path))