Debian Codegraph @

debian/rust-vendor/aws-lc-sys/aws-lc/crypto/x509/x509_d2.c

raw
1 // Copyright (C) 1995-1998 Eric Young ([email protected]) All rights reserved.
2 // SPDX-License-Identifier: Apache-2.0
3
4 #include <openssl/err.h>
5 #include <openssl/x509.h>
6
7
8 int X509_STORE_set_default_paths(X509_STORE *ctx) {
9 X509_LOOKUP *lookup;
10
11 lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_file());
12 if (lookup == NULL) {
13 return 0;
14 }
15 X509_LOOKUP_load_file(lookup, NULL, X509_FILETYPE_DEFAULT);
16
17 lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_hash_dir());
18 if (lookup == NULL) {
19 return 0;
20 }
21 X509_LOOKUP_add_dir(lookup, NULL, X509_FILETYPE_DEFAULT);
22
23 // clear any errors
24 ERR_clear_error();
25
26 return 1;
27 }
28
29 int X509_STORE_load_locations(X509_STORE *ctx, const char *file,
30 const char *path) {
31 X509_LOOKUP *lookup;
32
33 if (file != NULL) {
34 lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_file());
35 if (lookup == NULL) {
36 return 0;
37 }
38 if (X509_LOOKUP_load_file(lookup, file, X509_FILETYPE_PEM) != 1) {
39 return 0;
40 }
41 }
42 if (path != NULL) {
43 lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_hash_dir());
44 if (lookup == NULL) {
45 return 0;
46 }
47 if (X509_LOOKUP_add_dir(lookup, path, X509_FILETYPE_PEM) != 1) {
48 return 0;
49 }
50 }
51 if ((path == NULL) && (file == NULL)) {
52 return 0;
53 }
54 return 1;
55 }