OpenVPN 3 Core Library
Loading...
Searching...
No Matches
awsca.hpp
Go to the documentation of this file.
1
// OpenVPN -- An application to securely tunnel IP networks
2
// over a single port, with support for SSL/TLS-based
3
// session authentication and key exchange,
4
// packet encryption, packet authentication, and
5
// packet compression.
6
//
7
// Copyright (C) 2012- OpenVPN Inc.
8
//
9
// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10
//
11
12
// AWS API CA
13
14
#pragma once
15
16
#include <filesystem>
17
#include <
openvpn/common/fileunix.hpp
>
18
#include <
openvpn/common/stat.hpp
>
19
20
namespace
openvpn::AWS
{
21
inline
std::string
api_ca
()
22
{
23
// paths are copied from https://golang.org/src/crypto/x509/root_linux.go
24
std::list<std::string> certs = {
25
"/etc/ssl/certs/ca-certificates.crt"
,
// debian/ubuntu
26
"/etc/pki/tls/certs/ca-bundle.crt"
,
// fedora/rhel6
27
"/etc/ssl/ca-bundle.pem"
,
// opensuse,
28
"/etc/pki/tls/cacert.pem"
// openelec
29
"/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem"
// centos/rhel7
30
"/etc/ssl/cert.pem"
// alpine
31
};
32
for
(
const
auto
&cert : certs)
33
{
34
std::error_code ec;
35
if
(std::filesystem::exists(cert, ec))
36
return
read_text_unix
(cert);
37
}
38
throw
file_unix_error(
"No CA certificate files found in system paths"
);
39
}
40
}
// namespace openvpn::AWS
fileunix.hpp
openvpn::AWS
Definition
awsca.hpp:20
openvpn::AWS::api_ca
std::string api_ca()
Definition
awsca.hpp:21
openvpn::read_text_unix
std::string read_text_unix(const std::string &filename, const std::uint64_t max_size=0, const unsigned int enoent_option=0, std::uint64_t *mtime_ns=nullptr)
Definition
fileunix.hpp:195
stat.hpp
openvpn
aws
awsca.hpp
Generated by
1.9.8