/src/libreoffice/include/systools/opensslinit.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | */ |
9 | | |
10 | | #pragma once |
11 | | |
12 | | #include <config_crypto.h> |
13 | | |
14 | | // Also include/systools/curlinit.hxx needs GetCABundleFile() if |
15 | | // !defined(SYSTEM_CURL) it defines LO_CURL_NEEDS_CA_BUNDLE. |
16 | | #if !defined(_WIN32) && (!defined(SYSTEM_OPENSSL) || defined(LO_CURL_NEEDS_CA_BUNDLE)) |
17 | | |
18 | | #include <unistd.h> |
19 | | |
20 | | static char const* GetCABundleFile() |
21 | 0 | { |
22 | | // try system ones first; inspired by: |
23 | | // https://www.happyassassin.net/posts/2015/01/12/a-note-about-ssltls-trusted-certificate-stores-and-platforms/ |
24 | 0 | auto const candidates = { |
25 | 0 | "/etc/pki/tls/certs/ca-bundle.crt", |
26 | 0 | "/etc/pki/tls/certs/ca-bundle.trust.crt", |
27 | 0 | "/etc/ssl/certs/ca-certificates.crt", |
28 | 0 | "/var/lib/ca-certificates/ca-bundle.pem", |
29 | 0 | "/etc/ssl/cert.pem", // macOS has one at this location |
30 | 0 | }; |
31 | 0 | for (char const* const candidate : candidates) |
32 | 0 | { |
33 | 0 | if (access(candidate, R_OK) == 0) |
34 | 0 | { |
35 | 0 | return candidate; |
36 | 0 | } |
37 | 0 | } |
38 | | |
39 | 0 | return nullptr; |
40 | 0 | } |
41 | | #endif |
42 | | |
43 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |