Coverage Report

Created: 2018-08-29 13:53

/src/openssl/crypto/x509/x509_d2.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3
 *
4
 * Licensed under the OpenSSL license (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
8
 */
9
10
#include <stdio.h>
11
#include "internal/cryptlib.h"
12
#include <openssl/crypto.h>
13
#include <openssl/x509.h>
14
15
int X509_STORE_set_default_paths(X509_STORE *ctx)
16
0
{
17
0
    X509_LOOKUP *lookup;
18
0
19
0
    lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_file());
20
0
    if (lookup == NULL)
21
0
        return 0;
22
0
    X509_LOOKUP_load_file(lookup, NULL, X509_FILETYPE_DEFAULT);
23
0
24
0
    lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_hash_dir());
25
0
    if (lookup == NULL)
26
0
        return 0;
27
0
    X509_LOOKUP_add_dir(lookup, NULL, X509_FILETYPE_DEFAULT);
28
0
29
0
    /* clear any errors */
30
0
    ERR_clear_error();
31
0
32
0
    return 1;
33
0
}
34
35
int X509_STORE_load_locations(X509_STORE *ctx, const char *file,
36
                              const char *path)
37
0
{
38
0
    X509_LOOKUP *lookup;
39
0
40
0
    if (file != NULL) {
41
0
        lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_file());
42
0
        if (lookup == NULL)
43
0
            return 0;
44
0
        if (X509_LOOKUP_load_file(lookup, file, X509_FILETYPE_PEM) != 1)
45
0
            return 0;
46
0
    }
47
0
    if (path != NULL) {
48
0
        lookup = X509_STORE_add_lookup(ctx, X509_LOOKUP_hash_dir());
49
0
        if (lookup == NULL)
50
0
            return 0;
51
0
        if (X509_LOOKUP_add_dir(lookup, path, X509_FILETYPE_PEM) != 1)
52
0
            return 0;
53
0
    }
54
0
    if ((path == NULL) && (file == NULL))
55
0
        return 0;
56
0
    return 1;
57
0
}