Motion Master 6.0.0-alpha.50
Next-generation motion control software
Loading...
Searching...
No Matches
cert_updater.h
Go to the documentation of this file.
1#pragma once
2
3#include <expected>
4#include <filesystem>
5#include <string>
6
7namespace mm {
8
13inline std::string defaultCertUrl() {
14 return "https://github.com/synapticon/motion-master/releases/download/tls-cert/cert.pem";
15}
16
18inline std::string defaultKeyUrl() {
19 return "https://github.com/synapticon/motion-master/releases/download/tls-cert/key.pem";
20}
21
38std::expected<void, std::string> fetchAndSwapCert(const std::string& certPath,
39 const std::string& keyPath,
40 const std::string& certUrl,
41 const std::string& keyUrl);
42
45 std::string certPath;
46 std::string keyPath;
49 std::string source;
50};
51
66ResolvedCert resolveCertPaths(const std::string& configCertPath, const std::string& configKeyPath,
67 const std::filesystem::path& defaultCertPath,
68 const std::filesystem::path& defaultKeyPath);
69
91std::expected<void, std::string> healCertIfNeeded(const std::string& certPath,
92 const std::string& keyPath, bool autoUpdate,
93 const std::string& certUrl,
94 const std::string& keyUrl);
95
96} // namespace mm
Definition cert_info.cc:13
std::string defaultKeyUrl()
Default rolling-release URL for the current TLS private key. See defaultCertUrl.
Definition cert_updater.h:18
ResolvedCert resolveCertPaths(const std::string &configCertPath, const std::string &configKeyPath, const std::filesystem::path &defaultCertPath, const std::filesystem::path &defaultKeyPath)
Resolve the TLS cert/key file paths, choosing by discovery when not configured.
Definition cert_updater.cc:182
std::string defaultCertUrl()
Default rolling-release URL for the current TLS certificate.
Definition cert_updater.h:13
std::expected< void, std::string > fetchAndSwapCert(const std::string &certPath, const std::string &keyPath, const std::string &certUrl, const std::string &keyUrl)
Downloads a fresh certificate and key and atomically installs them.
Definition cert_updater.cc:149
std::expected< void, std::string > healCertIfNeeded(const std::string &certPath, const std::string &keyPath, bool autoUpdate, const std::string &certUrl, const std::string &keyUrl)
Assess the served TLS certificate and refresh it if missing, expired, or expiring soon (the startup "...
Definition cert_updater.cc:214
The TLS cert/key paths the server should use, plus where they came from.
Definition cert_updater.h:44
std::string keyPath
Definition cert_updater.h:46
std::string source
Definition cert_updater.h:49
std::string certPath
Resolved certificate path (always populated).
Definition cert_updater.h:45