Coverage Report

Created: 2025-06-11 06:41

/src/boringssl/crypto/x509/x509_d2.cc
Line
Count
Source (jump to first uncovered line)
1
// Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     https://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#include <openssl/err.h>
16
#include <openssl/x509.h>
17
18
19
0
int X509_STORE_set_default_paths(X509_STORE *ctx) {
20
0
  X509_LOOKUP *lookup;
21
22
0
  lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_file());
23
0
  if (lookup == NULL) {
24
0
    return 0;
25
0
  }
26
0
  X509_LOOKUP_load_file(lookup, NULL, X509_FILETYPE_DEFAULT);
27
28
0
  lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_hash_dir());
29
0
  if (lookup == NULL) {
30
0
    return 0;
31
0
  }
32
0
  X509_LOOKUP_add_dir(lookup, NULL, X509_FILETYPE_DEFAULT);
33
34
  // clear any errors
35
0
  ERR_clear_error();
36
37
0
  return 1;
38
0
}
39
40
int X509_STORE_load_locations(X509_STORE *ctx, const char *file,
41
0
                              const char *path) {
42
0
  X509_LOOKUP *lookup;
43
44
0
  if (file != NULL) {
45
0
    lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_file());
46
0
    if (lookup == NULL) {
47
0
      return 0;
48
0
    }
49
0
    if (X509_LOOKUP_load_file(lookup, file, X509_FILETYPE_PEM) != 1) {
50
0
      return 0;
51
0
    }
52
0
  }
53
0
  if (path != NULL) {
54
0
    lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_hash_dir());
55
0
    if (lookup == NULL) {
56
0
      return 0;
57
0
    }
58
0
    if (X509_LOOKUP_add_dir(lookup, path, X509_FILETYPE_PEM) != 1) {
59
0
      return 0;
60
0
    }
61
0
  }
62
0
  if ((path == NULL) && (file == NULL)) {
63
0
    return 0;
64
0
  }
65
0
  return 1;
66
0
}