xentara-plugin v2.0.3
The Xentara Plugin Framework
Loading...
Searching...
No Matches
xentara::security::CertificatePaths Class Referencefinal

Paths to the files containing a TLS certificate and the associated private key. More...

#include <xentara/security/CertificatePaths.hpp>

Public Member Functions

 CertificatePaths ()=default
 Default constructor.
 
template<typename CertificatePath , typename PrivateKeyPath >
requires (std::is_constructible_v<std::filesystem::path, CertificatePath &&> && std::is_constructible_v<std::filesystem::path, PrivateKeyPath &&>)
 CertificatePaths (CertificatePath &&certificatePath, PrivateKeyPath &&privateKeyPath)
 Constructor that sets the paths.
 
auto empty () const noexcept -> bool
 Checks whether the object contains any paths.
 
constexpr auto certificatePath () const noexcept -> const std::filesystem::path &
 Gets the path to the PEM file containing the certificate.
 
constexpr auto privateKeyPath () const noexcept -> const std::filesystem::path &
 Gets the path to the PEM file containing the private key.
 
auto load (utils::json::decoder::Value &value, config::Context &context) -> void
 Loads the certificate paths from a value.
 

Static Public Member Functions

static auto certificateSubdirectory () -> std::filesystem::path
 Gets the config sub-directory for certificates.
 
static auto privateKeySubdirectory () -> std::filesystem::path
 Gets the config sub-directory for private keys.
 

Detailed Description

Paths to the files containing a TLS certificate and the associated private key.

This class implements all the functionality necessary for using structured bindings. This means that you can bind individual names to the two certificate paths using structured binding syntax:

auto && [certificatePath, privateKeyPath] = mySecurityContext.serverCertificate();
constexpr auto privateKeyPath() const noexcept -> const std::filesystem::path &
Gets the path to the PEM file containing the private key.
Definition CertificatePaths.hpp:64
constexpr auto certificatePath() const noexcept -> const std::filesystem::path &
Gets the path to the PEM file containing the certificate.
Definition CertificatePaths.hpp:58

Constructor & Destructor Documentation

◆ CertificatePaths() [1/2]

xentara::security::CertificatePaths::CertificatePaths ( )
default

Default constructor.

This constructor creates a dummy object that contains empty paths for both the certificate and the private key.

◆ CertificatePaths() [2/2]

template<typename CertificatePath , typename PrivateKeyPath >
requires (std::is_constructible_v<std::filesystem::path, CertificatePath &&> && std::is_constructible_v<std::filesystem::path, PrivateKeyPath &&>)
xentara::security::CertificatePaths::CertificatePaths ( CertificatePath &&  certificatePath,
PrivateKeyPath &&  privateKeyPath 
)

Constructor that sets the paths.

Parameters
certificatePathThe absolute path to the PEM file containing the certificate, or an empty path to create an empty object. If the path is empty, privateKeyPath must also be empty.
privateKeyPathThe absolute path to the PEM file containing the private key, or an empty path to create an empty object. If the path is empty, certificatePath must also be empty.

Member Function Documentation

◆ certificatePath()

constexpr auto xentara::security::CertificatePaths::certificatePath ( ) const -> const std::filesystem::path &
constexprnoexcept

Gets the path to the PEM file containing the certificate.

◆ certificateSubdirectory()

static auto xentara::security::CertificatePaths::certificateSubdirectory ( ) -> std::filesystem::path
static

Gets the config sub-directory for certificates.

This function returns the subdirectory below the actual config directories that this class uses when searching for certificates if the path in the configuration file is relative.

Returns
The subdirectory for certificates below the actual config directories. This path can be passed to config::Context::findConfigFile() to search for custom files in the certificate directories.

◆ empty()

auto xentara::security::CertificatePaths::empty ( ) const -> bool
noexcept

Checks whether the object contains any paths.

Returns
true if both the certificate path and the private key path are empty, or false if at least one of the paths is non-empty.

◆ load()

auto xentara::security::CertificatePaths::load ( utils::json::decoder::Value value,
config::Context context 
) -> void

Loads the certificate paths from a value.

Parameters
valueThe value to load the certificate paths from
contextThe configuration context.
Exceptions
std::runtime_errorThe configuration is not valid, or another error occurred.

◆ privateKeyPath()

constexpr auto xentara::security::CertificatePaths::privateKeyPath ( ) const -> const std::filesystem::path &
constexprnoexcept

Gets the path to the PEM file containing the private key.

◆ privateKeySubdirectory()

static auto xentara::security::CertificatePaths::privateKeySubdirectory ( ) -> std::filesystem::path
static

Gets the config sub-directory for private keys.

This function returns the subdirectory below the actual config directories that this class uses when searching for private keys if the path in the configuration file is relative.

Returns
The subdirectory for certificates below the actual config directories. This path can be passed to config::Context::findConfigFile() to search for custom files in the private key directories.