blob: fad89fc2bc95be3a5574bd9510cb21dafe6bb7eb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright OpenBMC Authors
#pragma once
#include <openssl/crypto.h>
#include <boost/asio/ssl/context.hpp>
#include <memory>
#include <optional>
#include <string>
namespace ensuressl
{
enum class VerifyCertificate
{
Verify,
NoVerify
};
constexpr const char* trustStorePath = "/etc/ssl/certs/authority";
constexpr const char* x509Comment = "Generated from OpenBMC service";
bool isTrustChainError(int errnum);
bool validateCertificate(X509* cert);
std::string verifyOpensslKeyCert(const std::string& filepath);
X509* loadCert(const std::string& filePath);
int addExt(X509* cert, int nid, const char* value);
std::string generateSslCertificate(const std::string& cn);
void writeCertificateToFile(const std::string& filepath,
const std::string& certificate);
std::string ensureOpensslKeyPresentAndValid(const std::string& filepath);
std::shared_ptr<boost::asio::ssl::context> getSslServerContext();
std::optional<boost::asio::ssl::context> getSSLClientContext(
VerifyCertificate verifyCertificate);
} // namespace ensuressl
|